ARTEMIS-577 log SSLHandshakeException root cause

This commit is contained in:
jbertram 2016-08-12 13:57:11 -05:00 committed by Clebert Suconic
parent cfbe06f3bc
commit 6038db8b99
1 changed files with 13 additions and 1 deletions

View File

@ -763,12 +763,24 @@ public class NettyAcceptor extends AbstractAcceptor {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (cause.getMessage() != null && cause.getMessage().startsWith(SSLHandshakeException.class.getName())) {
ActiveMQServerLogger.LOGGER.sslHandshakeFailed(ctx.channel().remoteAddress().toString(), cause.getMessage());
Throwable rootCause = getRootCause(cause);
String errorMessage = rootCause.getClass().getName() + ": " + rootCause.getMessage();
ActiveMQServerLogger.LOGGER.sslHandshakeFailed(ctx.channel().remoteAddress().toString(), errorMessage);
if (ActiveMQServerLogger.LOGGER.isDebugEnabled()) {
ActiveMQServerLogger.LOGGER.debug("SSL handshake failed", cause);
}
}
}
private Throwable getRootCause(Throwable throwable) {
List<Throwable> list = new ArrayList<>();
while (throwable != null && list.contains(throwable) == false) {
list.add(throwable);
throwable = throwable.getCause();
}
return (list.size() < 2 ? throwable : list.get(list.size() - 1));
}
}
}