Skip to content

Commit

Permalink
Only try to match SSLException message when debug logging is enabled.
Browse files Browse the repository at this point in the history
Motivation:

We only want to log for the particular case when debug logging is enabled so we not need to try to match the message if this is not the case.

Modifications:

Guard with logger.isDebugEnabled()

Result:

Less overhead when debug logging is not enabled.
  • Loading branch information
normanmaurer committed Dec 5, 2017
1 parent 2eddc92 commit ca1e1fc
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions handler/src/main/java/io/netty/handler/ssl/SslHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1506,13 +1506,15 @@ private void setHandshakeFailure(ChannelHandlerContext ctx, Throwable cause, boo
try {
engine.closeInbound();
} catch (SSLException e) {
// only log in debug mode as it most likely harmless and latest chrome still trigger
// this all the time.
//
// See https://github.com/netty/netty/issues/1340
String msg = e.getMessage();
if (msg == null || !msg.contains("possible truncation attack")) {
logger.debug("{} SSLEngine.closeInbound() raised an exception.", ctx.channel(), e);
if (logger.isDebugEnabled()) {
// only log in debug mode as it most likely harmless and latest chrome still trigger
// this all the time.
//
// See https://github.com/netty/netty/issues/1340
String msg = e.getMessage();
if (msg == null || !msg.contains("possible truncation attack")) {
logger.debug("{} SSLEngine.closeInbound() raised an exception.", ctx.channel(), e);
}
}
}
}
Expand Down

0 comments on commit ca1e1fc

Please sign in to comment.