Reduce a bind failure to trace logging (#46891)

Due to recent changes in the nio transport, a failure to bind the server
channel has started to be logged at an error level. This exception leads
to an automatic retry on a different port, so it should only be logged
at a trace level.
This commit is contained in:
Tim Brooks 2019-09-20 11:09:36 -06:00
parent 22dade8e1b
commit f02582de4b
No known key found for this signature in database
GPG Key ID: C2AA3BB91A889E77
2 changed files with 8 additions and 2 deletions

View File

@ -22,6 +22,7 @@ package org.elasticsearch.nio;
import org.elasticsearch.common.concurrent.CompletableContext;
import java.io.IOException;
import java.net.BindException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.nio.channels.ServerSocketChannel;
@ -78,7 +79,8 @@ public class ServerChannelContext extends ChannelContext<ServerSocketChannel> {
rawChannel.bind(localAddress);
bindContext.complete(null);
} catch (IOException e) {
IOException exception = new IOException("Failed to bind server socket channel {localAddress=" + localAddress + "}.", e);
BindException exception = new BindException("Failed to bind server socket channel {localAddress=" + localAddress + "}.");
exception.initCause(e);
bindContext.completeExceptionally(exception);
throw exception;
}

View File

@ -618,7 +618,11 @@ public abstract class TcpTransport extends AbstractLifecycleComponent implements
}
protected void onServerException(TcpServerChannel channel, Exception e) {
logger.error(new ParameterizedMessage("exception from server channel caught on transport layer [channel={}]", channel), e);
if (e instanceof BindException) {
logger.trace(() -> new ParameterizedMessage("bind exception from server channel caught on transport layer [{}]", channel), e);
} else {
logger.error(new ParameterizedMessage("exception from server channel caught on transport layer [{}]", channel), e);
}
}
protected void serverAcceptedChannel(TcpChannel channel) {