Repository: activemq-artemis
Updated Branches:
  refs/heads/master 113c2a347 -> a349ebfab


ARTEMIS-577 log SSLHandshakeException root cause


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/6038db8b
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/6038db8b
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/6038db8b

Branch: refs/heads/master
Commit: 6038db8b99784b1ef21d863086ebf129f0b6b3f4
Parents: cfbe06f
Author: jbertram <[email protected]>
Authored: Fri Aug 12 13:57:11 2016 -0500
Committer: Clebert Suconic <[email protected]>
Committed: Mon Aug 15 13:58:25 2016 -0400

----------------------------------------------------------------------
 .../core/remoting/impl/netty/NettyAcceptor.java       | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6038db8b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
index ce506cb..783f4ac 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
@@ -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));
+      }
    }
 }

Reply via email to