This is an automated email from the ASF dual-hosted git repository.

lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git

commit 23b9fd5d7b7faa0b3bc72e66bd9b176b3877e7f8
Author: Lyor Goldstein <[email protected]>
AuthorDate: Tue Feb 12 12:55:12 2019 +0200

    Log caught session exception cause if available
---
 .../apache/sshd/common/session/helpers/SessionHelper.java | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git 
a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
 
b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
index a996d6d..41e85ac 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
@@ -1022,9 +1022,22 @@ public abstract class SessionHelper extends 
AbstractKexFactoryManager implements
             return;
         }
 
-        log.warn("exceptionCaught({})[state={}] {}: {}", this, curState, 
t.getClass().getSimpleName(), t.getMessage());
+        log.warn("exceptionCaught({})[state={}] {}: {}",
+            this, curState, t.getClass().getSimpleName(), t.getMessage());
+        Throwable cause = t.getCause();
+        if ((cause != null) && GenericUtils.isSameReference(t, cause)) {
+            cause = null;
+        }
+        if (cause != null) {
+            log.warn("exceptionCaught({})[state={}] caused by {}: {}",
+                this, curState, cause.getClass().getSimpleName(), 
cause.getMessage());
+        }
+
         if (log.isDebugEnabled()) {
             log.debug("exceptionCaught(" + this + ")[state=" + curState + "] 
details", t);
+            if (cause != null) {
+                log.debug("exceptionCaught(" + this + ")[state=" + curState + 
"] cause", cause);
+            }
         }
 
         signalExceptionCaught(t);

Reply via email to