peterxcli commented on code in PR #18337:
URL: https://github.com/apache/kafka/pull/18337#discussion_r1901041202


##########
test-common/src/main/java/org/apache/kafka/common/test/PreboundSocketFactoryManager.java:
##########
@@ -49,7 +49,16 @@ public ServerSocketChannel openServerSocket(
             ServerSocketChannel socketChannel = 
getSocketForListenerAndMarkAsUsed(
                 nodeId,
                 listenerName);
-            if (socketChannel != null) {
+            if (socketChannel != null && socketChannel.isOpen()) {
+                return socketChannel;
+            } else if (socketChannel != null) {
+                // bind the server socket with same port
+                socketAddress = new 
InetSocketAddress(socketAddress.getHostString(), 
socketChannel.socket().getLocalPort());
+                socketChannel = ServerSocketFactory.INSTANCE.openServerSocket(
+                        listenerName,
+                        socketAddress,
+                        listenBacklogSize,
+                        recvBufferSize);
                 return socketChannel;
             }

Review Comment:
   Nice catch. Thanks!



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to