TanYuxin-tyx commented on code in PR #22471:
URL: https://github.com/apache/flink/pull/22471#discussion_r1174851201


##########
flink-queryable-state/flink-queryable-state-runtime/src/test/java/org/apache/flink/queryablestate/network/ClientTest.java:
##########
@@ -248,12 +251,30 @@ void testRequestUnavailableHost() throws Exception {
         try {
             client = new Client<>("Test Client", 1, serializer, stats);
 
-            InetSocketAddress serverAddress = new 
InetSocketAddress(InetAddress.getLocalHost(), 0);
-
-            KvStateInternalRequest request =
-                    new KvStateInternalRequest(new KvStateID(), new byte[0]);
-            CompletableFuture<KvStateResponse> future = 
client.sendRequest(serverAddress, request);
+            CompletableFuture<KvStateResponse> future;
+            Random random = new Random();
+            int numRetry = 0;
+            while (true) {
+                try {
+                    InetSocketAddress serverAddress =
+                            new InetSocketAddress(
+                                    InetAddress.getLocalHost(), 
random.nextInt(30000));
+
+                    KvStateInternalRequest request =
+                            new KvStateInternalRequest(new KvStateID(), new 
byte[0]);
+                    future = client.sendRequest(serverAddress, request);
+                    break;
+                } catch (Exception e) {
+                    if (ExceptionUtils.findThrowable(e, 
BindException.class).isPresent()
+                            && numRetry <= numTryCreateSocketAddress) {
+                        numRetry++;
+                    } else {
+                        throw e;
+                    }
+                }
+            }

Review Comment:
   Good point. Fixed.



-- 
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]

Reply via email to