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