jmckenzie-dev commented on code in PR #191:
URL: 
https://github.com/apache/cassandra-analytics/pull/191#discussion_r3028739068


##########
cassandra-analytics-integration-framework/src/main/java/org/apache/cassandra/sidecar/testing/SharedClusterIntegrationTestBase.java:
##########
@@ -217,8 +217,22 @@ private IClusterExtension<? extends IInstance> 
provisionClusterWithRetries(TestV
             }
             catch (RuntimeException rte)
             {
-                if (rte.getMessage() != null && 
(rte.getMessage().contains("Address already in use") ||
-                                                 rte.getMessage().contains("is 
in use by another")))
+                // The BindException ("Address already in use") is several 
levels deep in the cause
+                // chain when thrown through the reflection-based cluster 
provisioning path, so we
+                // must walk the full chain rather than checking only 
rte.getMessage().
+                boolean isBindFailure = false;
+                for (Throwable cause = rte; cause != null; cause = 
cause.getCause())
+                {
+                    String message = cause.getMessage();
+                    if (message != null && (message.contains("Address already 
in use") ||
+                                            message.contains("is in use by 
another") ||
+                                            message.contains("Failed to bind 
port")))
+                    {
+                        isBindFailure = true;
+                        break;
+                    }

Review Comment:
   This comes from our friend `Server.java#start` in Cassandra:
   ```
           if (!bindFuture.awaitUninterruptibly().isSuccess())
               throw new IllegalStateException(String.format("Failed to bind 
port %d on %s.", socket.getPort(), socket.getAddress().getHostAddress()),
                                               bindFuture.cause());
   ```
   Certainly if _that_ changes we could have a bad time. But the reality is 
that we're a) throwing an IllegalStateException in C*, and b) it's going 
through layers of indirection (C* inside in-jvm dtest API inside classloaders) 
that make it pretty hard to durably determine what exception type is going to 
show up in the test level since various tiers can catch and rethrow as 
different types.
   
   Hence the throwing my hands in the air and just strcmp'ing it for now. On 
the plus side, that string has been stable since at least 2018 so seems stable.
   
   Famous last words.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to