Skip to content

Commit e11c567

Browse files
committed
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.
1 parent d09965a commit e11c567

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

test/framework/src/main/java/org/elasticsearch/transport/nio/MockNioTransport.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
import java.util.concurrent.ConcurrentHashMap;
6868
import java.util.concurrent.ConcurrentMap;
6969
import java.util.concurrent.TimeUnit;
70-
import java.util.function.Consumer;
7170
import java.util.function.IntFunction;
7271
import java.util.function.Supplier;
7372
import java.util.stream.Collectors;
@@ -220,7 +219,7 @@ public MockSocketChannel createChannel(NioSelector selector, SocketChannel chann
220219
}
221220
};
222221
MockTcpReadWriteHandler readWriteHandler = new MockTcpReadWriteHandler(nioChannel, MockNioTransport.this);
223-
BytesChannelContext context = new BytesChannelContext(nioChannel, selector, socketConfig, (e) -> exceptionCaught(nioChannel, e),
222+
BytesChannelContext context = new BytesChannelContext(nioChannel, selector, socketConfig, e -> exceptionCaught(nioChannel, e),
224223
readWriteHandler, new InboundChannelBuffer(pageSupplier));
225224
nioChannel.setContext(context);
226225
nioChannel.addConnectListener((v, e) -> {
@@ -240,10 +239,8 @@ public MockSocketChannel createChannel(NioSelector selector, SocketChannel chann
240239
@Override
241240
public MockServerChannel createServerChannel(NioSelector selector, ServerSocketChannel channel, Config.ServerSocket socketConfig) {
242241
MockServerChannel nioServerChannel = new MockServerChannel(channel);
243-
Consumer<Exception> exceptionHandler = (e) -> logger.error(() ->
244-
new ParameterizedMessage("exception from server channel caught on transport layer [{}]", channel), e);
245242
ServerChannelContext context = new ServerChannelContext(nioServerChannel, this, selector, socketConfig,
246-
MockNioTransport.this::acceptChannel, exceptionHandler) {
243+
MockNioTransport.this::acceptChannel, e -> onServerException(nioServerChannel, e)) {
247244
@Override
248245
public void acceptChannels(Supplier<NioSelector> selectorSupplier) throws IOException {
249246
int acceptCount = 0;

0 commit comments

Comments
 (0)