Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-11.0.x

This commit is contained in:
Joakim Erdfelt 2021-08-25 06:03:54 -05:00
commit dcc58d5606
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
2 changed files with 17 additions and 3 deletions

View File

@ -486,7 +486,7 @@ public class ClientConnector extends ContainerLifeCycle
catch (Throwable x)
{
if (LOG.isDebugEnabled())
LOG.debug("Could not configure {} to {} on {}", option, value, channel);
LOG.debug("Could not configure {} to {} on {}", option, value, channel, x);
}
}

View File

@ -19,6 +19,7 @@ import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.net.SocketOption;
import java.net.StandardSocketOptions;
import java.nio.channels.Channel;
import java.nio.channels.SelectableChannel;
@ -332,10 +333,10 @@ public class ServerConnector extends AbstractNetworkConnector
{
InetSocketAddress bindAddress = getHost() == null ? new InetSocketAddress(getPort()) : new InetSocketAddress(getHost(), getPort());
serverChannel = ServerSocketChannel.open();
setSocketOption(serverChannel, StandardSocketOptions.SO_REUSEADDR, getReuseAddress());
setSocketOption(serverChannel, StandardSocketOptions.SO_REUSEPORT, isReusePort());
try
{
serverChannel.setOption(StandardSocketOptions.SO_REUSEADDR, getReuseAddress());
serverChannel.setOption(StandardSocketOptions.SO_REUSEPORT, isReusePort());
serverChannel.bind(bindAddress, getAcceptQueueSize());
}
catch (Throwable e)
@ -348,6 +349,19 @@ public class ServerConnector extends AbstractNetworkConnector
return serverChannel;
}
private <T> void setSocketOption(ServerSocketChannel channel, SocketOption<T> option, T value)
{
try
{
channel.setOption(option, value);
}
catch (Throwable x)
{
if (LOG.isDebugEnabled())
LOG.debug("Could not configure {} to {} on {}", option, value, channel, x);
}
}
@Override
public void close()
{