frankvicky commented on code in PR #18337:
URL: https://github.com/apache/kafka/pull/18337#discussion_r1899256926
##########
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:
Please combine the null checks.
Instead of checking for `socketChannel != null` twice, we can combine them
into a single block that handles the non-null case.
--
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]