Check if logging level is enabled before log. See #192
This commit is contained in:
parent
0cc8153aa6
commit
fc16ab2d64
@ -47,9 +47,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;
|
||||
}
|
||||
@ -396,9 +398,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -435,9 +439,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +348,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) {
|
||||
@ -545,8 +547,11 @@ 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;
|
||||
}
|
||||
|
||||
@ -628,9 +633,12 @@ 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;
|
||||
}
|
||||
|
||||
@ -644,7 +652,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -785,7 +795,10 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
|
||||
public void eventSunk(ChannelPipeline pipeline, ChannelEvent e) {
|
||||
logger.warn("Not attached yet; discarding: " + e);
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Not attached yet; discarding: " + e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void exceptionCaught(ChannelPipeline pipeline,
|
||||
|
@ -72,7 +72,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -364,9 +364,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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +213,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.
|
||||
@ -306,8 +308,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;
|
||||
}
|
||||
@ -324,8 +329,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 {
|
||||
|
@ -171,7 +171,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.
|
||||
|
@ -83,18 +83,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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -249,7 +256,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;
|
||||
}
|
||||
|
||||
@ -257,7 +266,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;
|
||||
}
|
||||
|
||||
@ -265,7 +276,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;
|
||||
}
|
||||
|
||||
@ -351,7 +364,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,7 +396,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -418,7 +435,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,8 +65,11 @@ 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);
|
||||
|
@ -248,8 +248,11 @@ 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) {
|
||||
@ -273,14 +276,20 @@ class NioServerSocketPipelineSink extends AbstractChannelSink {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -290,7 +299,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,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.
|
||||
@ -208,8 +210,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;
|
||||
}
|
||||
@ -226,8 +230,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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,11 @@ 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);
|
||||
|
@ -209,14 +209,20 @@ class OioServerSocketPipelineSink extends AbstractChannelSink {
|
||||
"Old I/O server worker (parentId: " +
|
||||
channel.getId() + ", " + channel + ')'));
|
||||
} 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) {
|
||||
@ -227,9 +233,10 @@ class OioServerSocketPipelineSink extends AbstractChannelSink {
|
||||
if (!channel.socket.isBound() || channel.socket.isClosed()) {
|
||||
break;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -511,7 +511,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -527,9 +529,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;
|
||||
}
|
||||
}
|
||||
@ -538,10 +543,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.
|
||||
@ -1097,9 +1104,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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1118,7 +1128,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()) {
|
||||
@ -1130,7 +1142,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 {
|
||||
|
@ -99,7 +99,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,7 +276,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -516,9 +516,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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user