Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
Description
The NioEchoServer calls Selector#register for new connections. This call can throw exceptions, which then kill the NioEchoServer. This has been observed in the SslTransportLayerTest testUngracefulRemoteCloseDuringHandshake* methods.
Exception in thread "echoserver" java.lang.IllegalStateException: There is already a connection for id 127.0.0.1:40007-127.0.0.1:43710 at org.apache.kafka.common.network.Selector.ensureNotRegistered(Selector.java:322) at org.apache.kafka.common.network.Selector.register(Selector.java:310) at org.apache.kafka.common.network.NioEchoServer.run(NioEchoServer.java:229)
This causes the test to fail with essentially a timeout, when the connection is expired for becoming idle unexpectedly:
org.opentest4j.AssertionFailedError: Unexpected channel state EXPIRED ==> expected: <true> but was: <false> at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151) at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132) at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63) at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36) at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:214) at org.apache.kafka.common.network.SslTransportLayerTest.testIOExceptionsDuringHandshake(SslTransportLayerTest.java:898) at org.apache.kafka.common.network.SslTransportLayerTest.testUngracefulRemoteCloseDuringHandshakeRead(SslTransportLayerTest.java:837)
Instead, the NioEchoServer should handle exceptions from register in a similar fashion to the SocketServer.
Attachments
Issue Links
- Discovered while testing
-
KAFKA-15845 Add Junit5 test extension which detects leaked Kafka clients and servers
- In Progress
- links to