Check if logging level is enabled before log. See #192
This commit is contained in:
parent
1b099acde0
commit
479def20bd
@ -518,9 +518,12 @@ public class HashedWheelTimer implements Timer {
|
|||||||
try {
|
try {
|
||||||
task.run(this);
|
task.run(this);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"An exception was thrown by " +
|
logger.warn(
|
||||||
TimerTask.class.getSimpleName() + ".", t);
|
"An exception was thrown by " +
|
||||||
|
TimerTask.class.getSimpleName() + ".", t);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,12 +43,14 @@ public class SharedResourceMisuseDetector {
|
|||||||
|
|
||||||
public void increase() {
|
public void increase() {
|
||||||
if (activeInstances.incrementAndGet() > MAX_ACTIVE_INSTANCES) {
|
if (activeInstances.incrementAndGet() > MAX_ACTIVE_INSTANCES) {
|
||||||
if (logged.compareAndSet(false, true)) {
|
if (logger.isWarnEnabled()) {
|
||||||
logger.warn(
|
if (logged.compareAndSet(false, true)) {
|
||||||
"You are creating too many " + type.getSimpleName() +
|
logger.warn(
|
||||||
" instances. " + type.getSimpleName() +
|
"You are creating too many " + type.getSimpleName() +
|
||||||
" is a shared resource that must be reused across the" +
|
" instances. " + type.getSimpleName() +
|
||||||
" application, so that only a few instances are created.");
|
" is a shared resource that must be reused across the" +
|
||||||
|
" application, so that only a few instances are created.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,8 +81,11 @@ public class AutobahnServerHandler extends SimpleChannelUpstreamHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
|
private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
|
||||||
logger.debug(String
|
if (logger.isDebugEnabled()) {
|
||||||
.format("Channel %s received %s", ctx.getChannel().getId(), frame.getClass().getSimpleName()));
|
logger.debug(String
|
||||||
|
.format("Channel %s received %s", ctx.getChannel().getId(), frame.getClass().getSimpleName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (frame instanceof CloseWebSocketFrame) {
|
if (frame instanceof CloseWebSocketFrame) {
|
||||||
this.handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) frame);
|
this.handshaker.close(ctx.getChannel(), (CloseWebSocketFrame) frame);
|
||||||
|
@ -116,7 +116,9 @@ public class WebSocketServerHandler extends SimpleChannelUpstreamHandler {
|
|||||||
|
|
||||||
// Send the uppercase string back.
|
// Send the uppercase string back.
|
||||||
String request = ((TextWebSocketFrame) frame).getText();
|
String request = ((TextWebSocketFrame) frame).getText();
|
||||||
logger.debug(String.format("Channel %s received %s", ctx.getChannel().getId(), request));
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug(String.format("Channel %s received %s", ctx.getChannel().getId(), request));
|
||||||
|
}
|
||||||
ctx.getChannel().write(new TextWebSocketFrame(request.toUpperCase()));
|
ctx.getChannel().write(new TextWebSocketFrame(request.toUpperCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,9 @@ public class WebSocketSslServerHandler extends SimpleChannelUpstreamHandler {
|
|||||||
|
|
||||||
// Send the uppercase string back.
|
// Send the uppercase string back.
|
||||||
String request = ((TextWebSocketFrame) frame).getText();
|
String request = ((TextWebSocketFrame) frame).getText();
|
||||||
logger.debug(String.format("Channel %s received %s", ctx.getChannel().getId(), request));
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug(String.format("Channel %s received %s", ctx.getChannel().getId(), request));
|
||||||
|
}
|
||||||
ctx.getChannel().write(new TextWebSocketFrame(request.toUpperCase()));
|
ctx.getChannel().write(new TextWebSocketFrame(request.toUpperCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,9 @@ public final class WebSocketSslServerSslContext {
|
|||||||
}
|
}
|
||||||
_serverContext = serverContext;
|
_serverContext = serverContext;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.error("Error initializing SslContextManager. " + ex.getMessage(), ex);
|
if (logger.isErrorEnabled()) {
|
||||||
|
logger.error("Error initializing SslContextManager. " + ex.getMessage(), ex);
|
||||||
|
}
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,9 @@ public class CIDR6 extends CIDR {
|
|||||||
try {
|
try {
|
||||||
return bigIntToIPv6Address(addressEndBigInt);
|
return bigIntToIPv6Address(addressEndBigInt);
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
logger.error("invalid ip address calculated as an end address");
|
if (logger.isErrorEnabled()) {
|
||||||
|
logger.error("invalid ip address calculated as an end address");
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,9 @@ public class IpFilterRuleList extends ArrayList<IpFilterRule> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(rule.startsWith("+") || rule.startsWith("-"))) {
|
if (!(rule.startsWith("+") || rule.startsWith("-"))) {
|
||||||
logger.error("syntax error in ip filter rule:" + rule);
|
if (logger.isErrorEnabled()) {
|
||||||
|
logger.error("syntax error in ip filter rule:" + rule);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,10 +82,14 @@ public class IpFilterRuleList extends ArrayList<IpFilterRule> {
|
|||||||
try {
|
try {
|
||||||
this.add(new IpSubnetFilterRule(allow, rule.substring(3)));
|
this.add(new IpSubnetFilterRule(allow, rule.substring(3)));
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
logger.error("error parsing ip filter " + rule, e);
|
if (logger.isErrorEnabled()) {
|
||||||
|
logger.error("error parsing ip filter " + rule, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.error("syntax error in ip filter rule:" + rule);
|
if (logger.isErrorEnabled()) {
|
||||||
|
logger.error("syntax error in ip filter rule:" + rule);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,9 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
logger.info("error getting ip of localhost", e);
|
if (logger.isInfoEnabled()) {
|
||||||
|
logger.info("error getting ip of localhost", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
InetAddress[] addrs = InetAddress.getAllByName("127.0.0.1");
|
InetAddress[] addrs = InetAddress.getAllByName("127.0.0.1");
|
||||||
@ -168,7 +170,9 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
logger.info("error getting ip of localhost", e);
|
if (logger.isInfoEnabled()) {
|
||||||
|
logger.info("error getting ip of localhost", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -497,7 +497,9 @@ public class SslHandler extends FrameDecoder
|
|||||||
try {
|
try {
|
||||||
engine.closeInbound();
|
engine.closeInbound();
|
||||||
} catch (SSLException ex) {
|
} catch (SSLException ex) {
|
||||||
logger.debug("Failed to clean up SSLEngine.", ex);
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("Failed to clean up SSLEngine.", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -513,9 +515,12 @@ public class SslHandler extends FrameDecoder
|
|||||||
synchronized (ignoreClosedChannelExceptionLock) {
|
synchronized (ignoreClosedChannelExceptionLock) {
|
||||||
if (ignoreClosedChannelException > 0) {
|
if (ignoreClosedChannelException > 0) {
|
||||||
ignoreClosedChannelException --;
|
ignoreClosedChannelException --;
|
||||||
logger.debug(
|
if (logger.isDebugEnabled()) {
|
||||||
"Swallowing an exception raised while " +
|
logger.debug(
|
||||||
"writing non-app data", cause);
|
"Swallowing an exception raised while " +
|
||||||
|
"writing non-app data", cause);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -524,10 +529,12 @@ public class SslHandler extends FrameDecoder
|
|||||||
if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
|
if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
|
||||||
// It is safe to ignore the 'connection reset by peer' or
|
// It is safe to ignore the 'connection reset by peer' or
|
||||||
// 'broken pipe' error after sending closure_notify.
|
// 'broken pipe' error after sending closure_notify.
|
||||||
logger.debug(
|
if (logger.isDebugEnabled()) {
|
||||||
"Swallowing a 'connection reset by peer / " +
|
logger.debug(
|
||||||
"broken pipe' error occurred while writing " +
|
"Swallowing a 'connection reset by peer / " +
|
||||||
"'closure_notify'", cause);
|
"broken pipe' error occurred while writing " +
|
||||||
|
"'closure_notify'", cause);
|
||||||
|
}
|
||||||
|
|
||||||
// Close the connection explicitly just in case the transport
|
// Close the connection explicitly just in case the transport
|
||||||
// did not close the connection automatically.
|
// did not close the connection automatically.
|
||||||
@ -1085,9 +1092,12 @@ public class SslHandler extends FrameDecoder
|
|||||||
try {
|
try {
|
||||||
engine.closeInbound();
|
engine.closeInbound();
|
||||||
} catch (SSLException e) {
|
} catch (SSLException e) {
|
||||||
logger.debug(
|
if (logger.isDebugEnabled()) {
|
||||||
"SSLEngine.closeInbound() raised an exception after " +
|
logger.debug(
|
||||||
"a handshake failure.", e);
|
"SSLEngine.closeInbound() raised an exception after " +
|
||||||
|
"a handshake failure.", e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1106,7 +1116,9 @@ public class SslHandler extends FrameDecoder
|
|||||||
try {
|
try {
|
||||||
unwrap(context, e.getChannel(), ChannelBuffers.EMPTY_BUFFER, 0, 0);
|
unwrap(context, e.getChannel(), ChannelBuffers.EMPTY_BUFFER, 0, 0);
|
||||||
} catch (SSLException ex) {
|
} catch (SSLException ex) {
|
||||||
logger.debug("Failed to unwrap before sending a close_notify message", ex);
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("Failed to unwrap before sending a close_notify message", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!engine.isInboundDone()) {
|
if (!engine.isInboundDone()) {
|
||||||
@ -1118,7 +1130,9 @@ public class SslHandler extends FrameDecoder
|
|||||||
new ClosingChannelFutureListener(context, e));
|
new ClosingChannelFutureListener(context, e));
|
||||||
success = true;
|
success = true;
|
||||||
} catch (SSLException ex) {
|
} catch (SSLException ex) {
|
||||||
logger.debug("Failed to encode a close_notify message", ex);
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("Failed to encode a close_notify message", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -92,7 +92,9 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns
|
|||||||
try {
|
try {
|
||||||
flush(ctx);
|
flush(ctx);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("Unexpected exception while sending chunks.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Unexpected exception while sending chunks.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +272,9 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns
|
|||||||
try {
|
try {
|
||||||
chunks.close();
|
chunks.close();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn("Failed to close a chunked input.", t);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to close a chunked input.", t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,9 @@ public abstract class AbstractSocketSslEchoTest {
|
|||||||
ChannelFuture ccf = cb.connect(new InetSocketAddress(SocketAddresses.LOCALHOST, port));
|
ChannelFuture ccf = cb.connect(new InetSocketAddress(SocketAddresses.LOCALHOST, port));
|
||||||
ccf.awaitUninterruptibly();
|
ccf.awaitUninterruptibly();
|
||||||
if (!ccf.isSuccess()) {
|
if (!ccf.isSuccess()) {
|
||||||
logger.error("Connection attempt failed", ccf.getCause());
|
if(logger.isErrorEnabled()) {
|
||||||
|
logger.error("Connection attempt failed", ccf.getCause());
|
||||||
|
}
|
||||||
sc.close().awaitUninterruptibly();
|
sc.close().awaitUninterruptibly();
|
||||||
}
|
}
|
||||||
assertTrue(ccf.isSuccess());
|
assertTrue(ccf.isSuccess());
|
||||||
@ -238,9 +240,11 @@ public abstract class AbstractSocketSslEchoTest {
|
|||||||
@Override
|
@Override
|
||||||
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
|
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Unexpected exception from the " +
|
logger.warn(
|
||||||
(server? "server" : "client") + " side", e.getCause());
|
"Unexpected exception from the " +
|
||||||
|
(server? "server" : "client") + " side", e.getCause());
|
||||||
|
}
|
||||||
|
|
||||||
exception.compareAndSet(null, e.getCause());
|
exception.compareAndSet(null, e.getCause());
|
||||||
e.getChannel().close();
|
e.getChannel().close();
|
||||||
|
@ -53,11 +53,13 @@ class DefaultNioSctpChannelConfig extends DefaultSctpChannelConfig implements Ni
|
|||||||
if (getWriteBufferHighWaterMark() < getWriteBufferLowWaterMark()) {
|
if (getWriteBufferHighWaterMark() < getWriteBufferLowWaterMark()) {
|
||||||
// Recover the integrity of the configuration with a sensible value.
|
// Recover the integrity of the configuration with a sensible value.
|
||||||
setWriteBufferLowWaterMark0(getWriteBufferHighWaterMark() >>> 1);
|
setWriteBufferLowWaterMark0(getWriteBufferHighWaterMark() >>> 1);
|
||||||
// Notify the user about misconfiguration.
|
if (logger.isWarnEnabled()) {
|
||||||
logger.warn(
|
// Notify the user about misconfiguration.
|
||||||
"writeBufferLowWaterMark cannot be greater than " +
|
logger.warn(
|
||||||
"writeBufferHighWaterMark; setting to the half of the " +
|
"writeBufferLowWaterMark cannot be greater than " +
|
||||||
"writeBufferHighWaterMark.");
|
"writeBufferHighWaterMark; setting to the half of the " +
|
||||||
|
"writeBufferHighWaterMark.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,9 +55,11 @@ final class SctpClientChannel extends SctpChannelImpl {
|
|||||||
try {
|
try {
|
||||||
underlayingChannel.close();
|
underlayingChannel.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to close a partially initialized socket.",
|
logger.warn(
|
||||||
e);
|
"Failed to close a partially initialized socket.",
|
||||||
|
e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,8 +289,10 @@ class SctpClientPipelineSink extends AbstractChannelSink {
|
|||||||
try {
|
try {
|
||||||
selector.close();
|
selector.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to close a selector.", e);
|
logger.warn(
|
||||||
|
"Failed to close a selector.", e);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.selector = null;
|
this.selector = null;
|
||||||
}
|
}
|
||||||
@ -307,8 +309,10 @@ class SctpClientPipelineSink extends AbstractChannelSink {
|
|||||||
shutdown = false;
|
shutdown = false;
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Unexpected exception in the selector loop.", t);
|
logger.warn(
|
||||||
|
"Unexpected exception in the selector loop.", t);
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent possible consecutive immediate failures.
|
// Prevent possible consecutive immediate failures.
|
||||||
try {
|
try {
|
||||||
|
@ -24,17 +24,12 @@ import com.sun.nio.sctp.SendFailedNotification;
|
|||||||
import com.sun.nio.sctp.ShutdownNotification;
|
import com.sun.nio.sctp.ShutdownNotification;
|
||||||
|
|
||||||
import io.netty.channel.Channels;
|
import io.netty.channel.Channels;
|
||||||
import io.netty.logging.InternalLogger;
|
|
||||||
import io.netty.logging.InternalLoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SctpNotificationHandler extends AbstractNotificationHandler {
|
class SctpNotificationHandler extends AbstractNotificationHandler {
|
||||||
|
|
||||||
private static final InternalLogger logger =
|
|
||||||
InternalLoggerFactory.getInstance(SctpNotificationHandler.class);
|
|
||||||
|
|
||||||
private final SctpChannelImpl sctpChannel;
|
private final SctpChannelImpl sctpChannel;
|
||||||
private final SctpWorker sctpWorker;
|
private final SctpWorker sctpWorker;
|
||||||
|
|
||||||
|
@ -61,8 +61,10 @@ final class SctpProviderMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (constraintLevel >= 0) {
|
if (constraintLevel >= 0) {
|
||||||
logger.debug(
|
if (logger.isDebugEnabled()) {
|
||||||
"Setting the NIO constraint level to: " + constraintLevel);
|
logger.debug(
|
||||||
|
"Setting the NIO constraint level to: " + constraintLevel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constraintLevel < 0) {
|
if (constraintLevel < 0) {
|
||||||
@ -70,18 +72,24 @@ final class SctpProviderMetadata {
|
|||||||
|
|
||||||
if (constraintLevel < 0) {
|
if (constraintLevel < 0) {
|
||||||
constraintLevel = 2;
|
constraintLevel = 2;
|
||||||
logger.debug(
|
if (logger.isDebugEnabled()) {
|
||||||
"Couldn't determine the NIO constraint level from " +
|
logger.debug(
|
||||||
"the system properties; using the safest level (2)");
|
"Couldn't determine the NIO constraint level from " +
|
||||||
|
"the system properties; using the safest level (2)");
|
||||||
|
}
|
||||||
} else if (constraintLevel != 0) {
|
} else if (constraintLevel != 0) {
|
||||||
logger.info(
|
if (logger.isInfoEnabled()) {
|
||||||
"Using the autodetected NIO constraint level: " +
|
logger.info(
|
||||||
constraintLevel +
|
"Using the autodetected NIO constraint level: " +
|
||||||
" (Use better NIO provider for better performance)");
|
constraintLevel +
|
||||||
|
" (Use better NIO provider for better performance)");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.debug(
|
if (logger.isDebugEnabled()) {
|
||||||
"Using the autodetected NIO constraint level: " +
|
logger.debug(
|
||||||
constraintLevel);
|
"Using the autodetected NIO constraint level: " +
|
||||||
|
constraintLevel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +244,9 @@ final class SctpProviderMetadata {
|
|||||||
ch.bind(new InetSocketAddress(0));
|
ch.bind(new InetSocketAddress(0));
|
||||||
ch.configureBlocking(false);
|
ch.configureBlocking(false);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.warn("Failed to configure a temporary socket.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to configure a temporary socket.", e);
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +254,9 @@ final class SctpProviderMetadata {
|
|||||||
try {
|
try {
|
||||||
loop = new SelectorLoop();
|
loop = new SelectorLoop();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.warn("Failed to open a temporary selector.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to open a temporary selector.", e);
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +264,9 @@ final class SctpProviderMetadata {
|
|||||||
try {
|
try {
|
||||||
ch.register(loop.selector, 0);
|
ch.register(loop.selector, 0);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.warn("Failed to register a temporary selector.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to register a temporary selector.", e);
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,7 +352,9 @@ final class SctpProviderMetadata {
|
|||||||
try {
|
try {
|
||||||
ch.close();
|
ch.close();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.warn("Failed to close a temporary socket.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to close a temporary socket.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,7 +384,9 @@ final class SctpProviderMetadata {
|
|||||||
try {
|
try {
|
||||||
loop.selector.close();
|
loop.selector.close();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.warn("Failed to close a temporary selector.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to close a temporary selector.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -406,7 +424,9 @@ final class SctpProviderMetadata {
|
|||||||
}
|
}
|
||||||
keys.clear();
|
keys.clear();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Failed to wait for a temporary selector.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to wait for a temporary selector.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,8 +71,10 @@ class SctpServerChannelImpl extends AbstractServerChannel
|
|||||||
try {
|
try {
|
||||||
serverChannel.close();
|
serverChannel.close();
|
||||||
} catch (IOException e2) {
|
} catch (IOException e2) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to close a partially initialized socket.", e2);
|
logger.warn(
|
||||||
|
"Failed to close a partially initialized socket.", e2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ChannelException("Failed to enter non-blocking mode.", e);
|
throw new ChannelException("Failed to enter non-blocking mode.", e);
|
||||||
|
@ -246,8 +246,10 @@ class SctpServerPipelineSink extends AbstractChannelSink {
|
|||||||
// Closed as requested.
|
// Closed as requested.
|
||||||
break;
|
break;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to accept a connection.", e);
|
logger.warn(
|
||||||
|
"Failed to accept a connection.", e);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException e1) {
|
} catch (InterruptedException e1) {
|
||||||
@ -271,14 +273,18 @@ class SctpServerPipelineSink extends AbstractChannelSink {
|
|||||||
SctpServerPipelineSink.this, acceptedSocket,
|
SctpServerPipelineSink.this, acceptedSocket,
|
||||||
worker, currentThread), null);
|
worker, currentThread), null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to initialize an accepted socket.", e);
|
logger.warn(
|
||||||
|
"Failed to initialize an accepted socket.", e);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
acceptedSocket.close();
|
acceptedSocket.close();
|
||||||
} catch (IOException e2) {
|
} catch (IOException e2) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to close a partially accepted socket.",
|
logger.warn(
|
||||||
e2);
|
"Failed to close a partially accepted socket.",
|
||||||
|
e2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -288,7 +294,9 @@ class SctpServerPipelineSink extends AbstractChannelSink {
|
|||||||
try {
|
try {
|
||||||
selector.close();
|
selector.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("Failed to close a selector.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to close a selector.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,9 @@ class SctpWorker implements Runnable {
|
|||||||
try {
|
try {
|
||||||
selector.close();
|
selector.close();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn("Failed to close a selector.", t);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to close a selector.", t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.selector = selector = null;
|
this.selector = selector = null;
|
||||||
// The method will return to the caller at this point.
|
// The method will return to the caller at this point.
|
||||||
@ -204,8 +206,10 @@ class SctpWorker implements Runnable {
|
|||||||
try {
|
try {
|
||||||
selector.close();
|
selector.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to close a selector.", e);
|
logger.warn(
|
||||||
|
"Failed to close a selector.", e);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.selector = null;
|
this.selector = null;
|
||||||
}
|
}
|
||||||
@ -222,9 +226,10 @@ class SctpWorker implements Runnable {
|
|||||||
shutdown = false;
|
shutdown = false;
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Unexpected exception in the selector loop.", t);
|
logger.warn(
|
||||||
|
"Unexpected exception in the selector loop.", t);
|
||||||
|
}
|
||||||
// Prevent possible consecutive immediate failures that lead to
|
// Prevent possible consecutive immediate failures that lead to
|
||||||
// excessive CPU consumption.
|
// excessive CPU consumption.
|
||||||
try {
|
try {
|
||||||
@ -313,7 +318,9 @@ class SctpWorker implements Runnable {
|
|||||||
if (messageInfo.isComplete()) {
|
if (messageInfo.isComplete()) {
|
||||||
failure = false;
|
failure = false;
|
||||||
} else {
|
} else {
|
||||||
logger.error("Received incomplete sctp packet, can not continue! Expected SCTP_EXPLICIT_COMPLETE message");
|
if (logger.isErrorEnabled()) {
|
||||||
|
logger.error("Received incomplete sctp packet, can not continue! Expected SCTP_EXPLICIT_COMPLETE message");
|
||||||
|
}
|
||||||
failure = true;
|
failure = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -32,10 +32,13 @@ final class SelectorUtil {
|
|||||||
try {
|
try {
|
||||||
selector.select(10); // does small timeout give more throughput + less CPU usage?
|
selector.select(10); // does small timeout give more throughput + less CPU usage?
|
||||||
} catch (CancelledKeyException e) {
|
} catch (CancelledKeyException e) {
|
||||||
// Harmless exception - log anyway
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug(
|
// Harmless exception - log anyway
|
||||||
CancelledKeyException.class.getSimpleName() +
|
logger.debug(
|
||||||
" raised by a Selector - JDK bug?", e);
|
CancelledKeyException.class.getSimpleName() +
|
||||||
|
" raised by a Selector - JDK bug?", e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,9 +48,11 @@ public abstract class CompleteChannelFuture implements ChannelFuture {
|
|||||||
try {
|
try {
|
||||||
listener.operationComplete(this);
|
listener.operationComplete(this);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"An exception was thrown by " +
|
logger.warn(
|
||||||
ChannelFutureListener.class.getSimpleName() + ".", t);
|
"An exception was thrown by " +
|
||||||
|
ChannelFutureListener.class.getSimpleName() + ".", t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,10 +56,12 @@ public class DefaultChannelFuture implements ChannelFuture {
|
|||||||
public static void setUseDeadLockChecker(boolean useDeadLockChecker) {
|
public static void setUseDeadLockChecker(boolean useDeadLockChecker) {
|
||||||
if (!useDeadLockChecker && !disabledDeadLockCheckerOnce) {
|
if (!useDeadLockChecker && !disabledDeadLockCheckerOnce) {
|
||||||
disabledDeadLockCheckerOnce = true;
|
disabledDeadLockCheckerOnce = true;
|
||||||
logger.debug(
|
if (logger.isDebugEnabled()) {
|
||||||
"The dead lock checker in " +
|
logger.debug(
|
||||||
DefaultChannelFuture.class.getSimpleName() +
|
"The dead lock checker in " +
|
||||||
" has been disabled as requested at your own risk.");
|
DefaultChannelFuture.class.getSimpleName() +
|
||||||
|
" has been disabled as requested at your own risk.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
DefaultChannelFuture.useDeadLockChecker = useDeadLockChecker;
|
DefaultChannelFuture.useDeadLockChecker = useDeadLockChecker;
|
||||||
}
|
}
|
||||||
@ -413,9 +415,11 @@ public class DefaultChannelFuture implements ChannelFuture {
|
|||||||
try {
|
try {
|
||||||
l.operationComplete(this);
|
l.operationComplete(this);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"An exception was thrown by " +
|
logger.warn(
|
||||||
ChannelFutureListener.class.getSimpleName() + ".", t);
|
"An exception was thrown by " +
|
||||||
|
ChannelFutureListener.class.getSimpleName() + ".", t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,9 +457,11 @@ public class DefaultChannelFuture implements ChannelFuture {
|
|||||||
try {
|
try {
|
||||||
l.operationProgressed(this, amount, current, total);
|
l.operationProgressed(this, amount, current, total);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"An exception was thrown by " +
|
logger.warn(
|
||||||
ChannelFutureProgressListener.class.getSimpleName() + ".", t);
|
"An exception was thrown by " +
|
||||||
|
ChannelFutureProgressListener.class.getSimpleName() + ".", t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,9 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
remove((DefaultChannelHandlerContext) ctx);
|
remove((DefaultChannelHandlerContext) ctx);
|
||||||
removed = true;
|
removed = true;
|
||||||
} catch (Throwable t2) {
|
} catch (Throwable t2) {
|
||||||
logger.warn("Failed to remove a handler: " + ctx.getName(), t2);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to remove a handler: " + ctx.getName(), t2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removed) {
|
if (removed) {
|
||||||
@ -564,8 +566,9 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
public void sendUpstream(ChannelEvent e) {
|
public void sendUpstream(ChannelEvent e) {
|
||||||
DefaultChannelHandlerContext head = getActualUpstreamContext(this.head);
|
DefaultChannelHandlerContext head = getActualUpstreamContext(this.head);
|
||||||
if (head == null) {
|
if (head == null) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"The pipeline contains no upstream handlers; discarding: " + e);
|
logger.warn("The pipeline contains no upstream handlers; discarding: " + e);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,9 +651,11 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
|
|
||||||
protected void notifyHandlerException(ChannelEvent e, Throwable t) {
|
protected void notifyHandlerException(ChannelEvent e, Throwable t) {
|
||||||
if (e instanceof ExceptionEvent) {
|
if (e instanceof ExceptionEvent) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"An exception was thrown by a user handler " +
|
logger.warn(
|
||||||
"while handling an exception event (" + e + ")", t);
|
"An exception was thrown by a user handler " +
|
||||||
|
"while handling an exception event (" + e + ")", t);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -664,7 +669,9 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
try {
|
try {
|
||||||
sink.exceptionCaught(this, e, pe);
|
sink.exceptionCaught(this, e, pe);
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
logger.warn("An exception was thrown by an exception handler.", e1);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("An exception was thrown by an exception handler.", e1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -815,7 +822,9 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void eventSunk(ChannelPipeline pipeline, ChannelEvent e) {
|
public void eventSunk(ChannelPipeline pipeline, ChannelEvent e) {
|
||||||
logger.warn("Not attached yet; discarding: " + e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Not attached yet; discarding: " + e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,7 +81,9 @@ public class DefaultFileRegion implements FileRegion {
|
|||||||
try {
|
try {
|
||||||
file.close();
|
file.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Failed to close a file.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to close a file.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -382,9 +382,11 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
|||||||
try {
|
try {
|
||||||
l.operationComplete(this);
|
l.operationComplete(this);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"An exception was thrown by " +
|
logger.warn(
|
||||||
ChannelFutureListener.class.getSimpleName() + ".", t);
|
"An exception was thrown by " +
|
||||||
|
ChannelFutureListener.class.getSimpleName() + ".", t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,8 +116,10 @@ final class LocalClientChannelSink extends AbstractChannelSink {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
future.setFailure(e);
|
future.setFailure(e);
|
||||||
fireExceptionCaught(channel, e);
|
fireExceptionCaught(channel, e);
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to initialize an accepted socket.", e);
|
logger.warn(
|
||||||
|
"Failed to initialize an accepted socket.", e);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,10 +47,13 @@ class DefaultNioDatagramChannelConfig extends DefaultDatagramChannelConfig
|
|||||||
if (getWriteBufferHighWaterMark() < getWriteBufferLowWaterMark()) {
|
if (getWriteBufferHighWaterMark() < getWriteBufferLowWaterMark()) {
|
||||||
// Recover the integrity of the configuration with a sensible value.
|
// Recover the integrity of the configuration with a sensible value.
|
||||||
setWriteBufferLowWaterMark0(getWriteBufferHighWaterMark() >>> 1);
|
setWriteBufferLowWaterMark0(getWriteBufferHighWaterMark() >>> 1);
|
||||||
// Notify the user about misconfiguration.
|
if (logger.isWarnEnabled()) {
|
||||||
logger.warn("writeBufferLowWaterMark cannot be greater than "
|
// Notify the user about misconfiguration.
|
||||||
+ "writeBufferHighWaterMark; setting to the half of the "
|
logger.warn("writeBufferLowWaterMark cannot be greater than "
|
||||||
+ "writeBufferHighWaterMark.");
|
+ "writeBufferHighWaterMark; setting to the half of the "
|
||||||
|
+ "writeBufferHighWaterMark.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,11 +55,14 @@ class DefaultNioSocketChannelConfig extends DefaultSocketChannelConfig
|
|||||||
if (getWriteBufferHighWaterMark() < getWriteBufferLowWaterMark()) {
|
if (getWriteBufferHighWaterMark() < getWriteBufferLowWaterMark()) {
|
||||||
// Recover the integrity of the configuration with a sensible value.
|
// Recover the integrity of the configuration with a sensible value.
|
||||||
setWriteBufferLowWaterMark0(getWriteBufferHighWaterMark() >>> 1);
|
setWriteBufferLowWaterMark0(getWriteBufferHighWaterMark() >>> 1);
|
||||||
// Notify the user about misconfiguration.
|
if (logger.isWarnEnabled()) {
|
||||||
logger.warn(
|
// Notify the user about misconfiguration.
|
||||||
"writeBufferLowWaterMark cannot be greater than " +
|
logger.warn(
|
||||||
"writeBufferHighWaterMark; setting to the half of the " +
|
"writeBufferLowWaterMark cannot be greater than " +
|
||||||
"writeBufferHighWaterMark.");
|
"writeBufferHighWaterMark; setting to the half of the " +
|
||||||
|
"writeBufferHighWaterMark.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,9 +52,12 @@ final class NioClientSocketChannel extends NioSocketChannel {
|
|||||||
try {
|
try {
|
||||||
socket.close();
|
socket.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to close a partially initialized socket.",
|
logger.warn(
|
||||||
e);
|
"Failed to close a partially initialized socket.",
|
||||||
|
e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,9 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
|
|||||||
try {
|
try {
|
||||||
selector.close();
|
selector.close();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn("Failed to close a selector.", t);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to close a selector.", t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.selector = selector = null;
|
this.selector = selector = null;
|
||||||
// The method will return to the caller at this point.
|
// The method will return to the caller at this point.
|
||||||
@ -302,8 +304,11 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
|
|||||||
try {
|
try {
|
||||||
selector.close();
|
selector.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to close a selector.", e);
|
logger.warn(
|
||||||
|
"Failed to close a selector.", e);
|
||||||
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
this.selector = null;
|
this.selector = null;
|
||||||
}
|
}
|
||||||
@ -320,8 +325,11 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
|
|||||||
shutdown = false;
|
shutdown = false;
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Unexpected exception in the selector loop.", t);
|
logger.warn(
|
||||||
|
"Unexpected exception in the selector loop.", t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Prevent possible consecutive immediate failures.
|
// Prevent possible consecutive immediate failures.
|
||||||
try {
|
try {
|
||||||
|
@ -155,7 +155,9 @@ class NioDatagramWorker implements Runnable {
|
|||||||
// Release the Selector if the execution fails.
|
// Release the Selector if the execution fails.
|
||||||
selector.close();
|
selector.close();
|
||||||
} catch (final Throwable t) {
|
} catch (final Throwable t) {
|
||||||
logger.warn("Failed to close a selector.", t);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to close a selector.", t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.selector = selector = null;
|
this.selector = selector = null;
|
||||||
// The method will return to the caller at this point.
|
// The method will return to the caller at this point.
|
||||||
|
@ -70,18 +70,25 @@ final class NioProviderMetadata {
|
|||||||
|
|
||||||
if (constraintLevel < 0) {
|
if (constraintLevel < 0) {
|
||||||
constraintLevel = 2;
|
constraintLevel = 2;
|
||||||
logger.debug(
|
if (logger.isDebugEnabled()) {
|
||||||
"Couldn't determine the NIO constraint level from " +
|
logger.debug(
|
||||||
"the system properties; using the safest level (2)");
|
"Couldn't determine the NIO constraint level from " +
|
||||||
|
"the system properties; using the safest level (2)");
|
||||||
|
}
|
||||||
} else if (constraintLevel != 0) {
|
} else if (constraintLevel != 0) {
|
||||||
logger.info(
|
if (logger.isInfoEnabled()) {
|
||||||
"Using the autodetected NIO constraint level: " +
|
logger.info(
|
||||||
constraintLevel +
|
"Using the autodetected NIO constraint level: " +
|
||||||
" (Use better NIO provider for better performance)");
|
constraintLevel +
|
||||||
|
" (Use better NIO provider for better performance)");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.debug(
|
if (logger.isDebugEnabled()) {
|
||||||
"Using the autodetected NIO constraint level: " +
|
logger.debug(
|
||||||
constraintLevel);
|
"Using the autodetected NIO constraint level: " +
|
||||||
|
constraintLevel);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +242,9 @@ final class NioProviderMetadata {
|
|||||||
ch.socket().bind(new InetSocketAddress(0));
|
ch.socket().bind(new InetSocketAddress(0));
|
||||||
ch.configureBlocking(false);
|
ch.configureBlocking(false);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.warn("Failed to configure a temporary socket.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to configure a temporary socket.", e);
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +252,9 @@ final class NioProviderMetadata {
|
|||||||
try {
|
try {
|
||||||
loop = new SelectorLoop();
|
loop = new SelectorLoop();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.warn("Failed to open a temporary selector.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to open a temporary selector.", e);
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +262,9 @@ final class NioProviderMetadata {
|
|||||||
try {
|
try {
|
||||||
ch.register(loop.selector, 0);
|
ch.register(loop.selector, 0);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.warn("Failed to register a temporary selector.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to register a temporary selector.", e);
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,7 +350,9 @@ final class NioProviderMetadata {
|
|||||||
try {
|
try {
|
||||||
ch.close();
|
ch.close();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.warn("Failed to close a temporary socket.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to close a temporary socket.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,7 +382,9 @@ final class NioProviderMetadata {
|
|||||||
try {
|
try {
|
||||||
loop.selector.close();
|
loop.selector.close();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.warn("Failed to close a temporary selector.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to close a temporary selector.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -405,7 +422,9 @@ final class NioProviderMetadata {
|
|||||||
}
|
}
|
||||||
keys.clear();
|
keys.clear();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Failed to wait for a temporary selector.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to wait for a temporary selector.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,11 @@ final class NioServerSocketChannel extends AbstractServerChannel
|
|||||||
try {
|
try {
|
||||||
socket.close();
|
socket.close();
|
||||||
} catch (IOException e2) {
|
} catch (IOException e2) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to close a partially initialized socket.", e2);
|
logger.warn(
|
||||||
|
"Failed to close a partially initialized socket.", e2);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ChannelException("Failed to enter non-blocking mode.", e);
|
throw new ChannelException("Failed to enter non-blocking mode.", e);
|
||||||
|
@ -243,8 +243,10 @@ class NioServerSocketPipelineSink extends AbstractChannelSink {
|
|||||||
// Closed as requested.
|
// Closed as requested.
|
||||||
break;
|
break;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to accept a connection.", e);
|
logger.warn(
|
||||||
|
"Failed to accept a connection.", e);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException e1) {
|
} catch (InterruptedException e1) {
|
||||||
@ -266,14 +268,18 @@ class NioServerSocketPipelineSink extends AbstractChannelSink {
|
|||||||
worker.register(NioAcceptedSocketChannel.create(channel.getFactory(), pipeline, channel,
|
worker.register(NioAcceptedSocketChannel.create(channel.getFactory(), pipeline, channel,
|
||||||
NioServerSocketPipelineSink.this, acceptedSocket, worker, currentThread), null);
|
NioServerSocketPipelineSink.this, acceptedSocket, worker, currentThread), null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to initialize an accepted socket.", e);
|
logger.warn(
|
||||||
|
"Failed to initialize an accepted socket.", e);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
acceptedSocket.close();
|
acceptedSocket.close();
|
||||||
} catch (IOException e2) {
|
} catch (IOException e2) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to close a partially accepted socket.",
|
logger.warn(
|
||||||
e2);
|
"Failed to close a partially accepted socket.",
|
||||||
|
e2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,7 +289,9 @@ class NioServerSocketPipelineSink extends AbstractChannelSink {
|
|||||||
try {
|
try {
|
||||||
selector.close();
|
selector.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("Failed to close a selector.", e);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to close a selector.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,9 @@ class NioWorker implements Runnable {
|
|||||||
try {
|
try {
|
||||||
selector.close();
|
selector.close();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn("Failed to close a selector.", t);
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Failed to close a selector.", t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.selector = selector = null;
|
this.selector = selector = null;
|
||||||
// The method will return to the caller at this point.
|
// The method will return to the caller at this point.
|
||||||
@ -197,8 +199,10 @@ class NioWorker implements Runnable {
|
|||||||
try {
|
try {
|
||||||
selector.close();
|
selector.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to close a selector.", e);
|
logger.warn(
|
||||||
|
"Failed to close a selector.", e);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.selector = null;
|
this.selector = null;
|
||||||
}
|
}
|
||||||
@ -215,8 +219,11 @@ class NioWorker implements Runnable {
|
|||||||
shutdown = false;
|
shutdown = false;
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Unexpected exception in the selector loop.", t);
|
logger.warn(
|
||||||
|
"Unexpected exception in the selector loop.", t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Prevent possible consecutive immediate failures that lead to
|
// Prevent possible consecutive immediate failures that lead to
|
||||||
// excessive CPU consumption.
|
// excessive CPU consumption.
|
||||||
|
@ -32,10 +32,13 @@ final class SelectorUtil {
|
|||||||
try {
|
try {
|
||||||
selector.select(500);
|
selector.select(500);
|
||||||
} catch (CancelledKeyException e) {
|
} catch (CancelledKeyException e) {
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug(
|
||||||
|
CancelledKeyException.class.getSimpleName() +
|
||||||
|
" raised by a Selector - JDK bug?", e);
|
||||||
|
}
|
||||||
// Harmless exception - log anyway
|
// Harmless exception - log anyway
|
||||||
logger.debug(
|
|
||||||
CancelledKeyException.class.getSimpleName() +
|
|
||||||
" raised by a Selector - JDK bug?", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +72,11 @@ final class OioServerSocketChannel extends AbstractServerChannel
|
|||||||
try {
|
try {
|
||||||
socket.close();
|
socket.close();
|
||||||
} catch (IOException e2) {
|
} catch (IOException e2) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to close a partially initialized socket.", e2);
|
logger.warn(
|
||||||
|
"Failed to close a partially initialized socket.", e2);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
throw new ChannelException(
|
throw new ChannelException(
|
||||||
"Failed to set the server socket timeout.", e);
|
"Failed to set the server socket timeout.", e);
|
||||||
|
@ -203,14 +203,18 @@ class OioServerSocketPipelineSink extends AbstractChannelSink {
|
|||||||
workerExecutor,
|
workerExecutor,
|
||||||
new OioWorker(acceptedChannel));
|
new OioWorker(acceptedChannel));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to initialize an accepted socket.", e);
|
logger.warn(
|
||||||
|
"Failed to initialize an accepted socket.", e);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
acceptedSocket.close();
|
acceptedSocket.close();
|
||||||
} catch (IOException e2) {
|
} catch (IOException e2) {
|
||||||
logger.warn(
|
if (logger.isWarnEnabled()) {
|
||||||
"Failed to close a partially accepted socket.",
|
logger.warn(
|
||||||
e2);
|
"Failed to close a partially accepted socket.",
|
||||||
|
e2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
@ -221,9 +225,12 @@ class OioServerSocketPipelineSink extends AbstractChannelSink {
|
|||||||
if (!channel.socket.isBound() || channel.socket.isClosed()) {
|
if (!channel.socket.isBound() || channel.socket.isClosed()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn(
|
||||||
|
"Failed to accept a connection.", e);
|
||||||
|
}
|
||||||
|
|
||||||
logger.warn(
|
|
||||||
"Failed to accept a connection.", e);
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException e1) {
|
} catch (InterruptedException e1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user