Fix bind failure logging for mock transport (#47150)

Currently the MockNioTransport uses a custom exception handler for
server channel exceptions. This means that bind failures are logged at
the warn level. This commit modifies the transport to use the common
TcpTransport exception handler which will log exceptions at the correct
level.
This commit is contained in:
Tim Brooks 2019-09-27 13:52:56 -06:00
parent d09965a6dd
commit e11c56760d
No known key found for this signature in database
GPG Key ID: C2AA3BB91A889E77
1 changed files with 2 additions and 5 deletions

View File

@ -67,7 +67,6 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.IntFunction;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@ -220,7 +219,7 @@ public class MockNioTransport extends TcpTransport {
}
};
MockTcpReadWriteHandler readWriteHandler = new MockTcpReadWriteHandler(nioChannel, MockNioTransport.this);
BytesChannelContext context = new BytesChannelContext(nioChannel, selector, socketConfig, (e) -> exceptionCaught(nioChannel, e),
BytesChannelContext context = new BytesChannelContext(nioChannel, selector, socketConfig, e -> exceptionCaught(nioChannel, e),
readWriteHandler, new InboundChannelBuffer(pageSupplier));
nioChannel.setContext(context);
nioChannel.addConnectListener((v, e) -> {
@ -240,10 +239,8 @@ public class MockNioTransport extends TcpTransport {
@Override
public MockServerChannel createServerChannel(NioSelector selector, ServerSocketChannel channel, Config.ServerSocket socketConfig) {
MockServerChannel nioServerChannel = new MockServerChannel(channel);
Consumer<Exception> exceptionHandler = (e) -> logger.error(() ->
new ParameterizedMessage("exception from server channel caught on transport layer [{}]", channel), e);
ServerChannelContext context = new ServerChannelContext(nioServerChannel, this, selector, socketConfig,
MockNioTransport.this::acceptChannel, exceptionHandler) {
MockNioTransport.this::acceptChannel, e -> onServerException(nioServerChannel, e)) {
@Override
public void acceptChannels(Supplier<NioSelector> selectorSupplier) throws IOException {
int acceptCount = 0;