You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "peterxcli (via GitHub)" <gi...@apache.org> on 2025/01/02 16:20:10 UTC
Re: [PR] KAFKA-18274: Failed to restart controller in testing due to closed socket channel [2/2] [kafka]
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org