From a85ba5311e1976b80f1c93f38d9f4a05c8c0e6fc Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 9 Jun 2015 13:43:05 +0200 Subject: [PATCH] Add more information to NotConnectedException --- .../main/java/org/jivesoftware/smack/SmackException.java | 5 +++++ .../org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/SmackException.java b/smack-core/src/main/java/org/jivesoftware/smack/SmackException.java index be7412d41..4bbe52f26 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/SmackException.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/SmackException.java @@ -166,6 +166,11 @@ public class SmackException extends Exception { public NotConnectedException() { super("Client is not, or no longer, connected"); } + + public NotConnectedException(XMPPConnection connection, String details) { + super("The connection " + connection.toString() + " is no longer connected. " + + details); + } } public static class IllegalStateChangeException extends SmackException { diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index dc07bd970..5748af9bd 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -1210,9 +1210,14 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { } protected void throwNotConnectedExceptionIfDoneAndResumptionNotPossible() throws NotConnectedException { - if (done() && !isSmResumptionPossible()) { + final boolean done = done(); + if (done) { + final boolean smResumptionPossbile = isSmResumptionPossible(); // Don't throw a NotConnectedException is there is an resumable stream available - throw new NotConnectedException(); + if (!smResumptionPossbile) { + throw new NotConnectedException(XMPPTCPConnection.this, "done=" + done + + " smResumptionPossible=" + smResumptionPossbile); + } } }