TESTS: Set SO_LINGER = 0 for MockNioTransport (#32560)

* TESTS: Set SO_LINGER = 0 for MockNioTransport

* Prevents lingering sockets in TIME_WAIT piling up during test runs and leading to port collisions that manifest as timeouts
* Fixes #32552
This commit is contained in:
Armin Braun 2018-09-19 06:05:36 +02:00 committed by GitHub
parent 99513b306e
commit 0cf0d73813
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View File

@ -182,6 +182,7 @@ public class MockTcpTransport extends TcpTransport {
executor.submit(() -> {
try {
socket.connect(address);
socket.setSoLinger(false, 0);
channel.loopRead(executor);
connectListener.onResponse(null);
} catch (Exception ex) {

View File

@ -193,6 +193,7 @@ public class MockNioTransport extends TcpTransport {
BytesChannelContext context = new BytesChannelContext(nioChannel, selector, (e) -> exceptionCaught(nioChannel, e),
readWriteHandler, new InboundChannelBuffer(pageSupplier));
nioChannel.setContext(context);
nioChannel.setSoLinger(0);
return nioChannel;
}