From 3187436ba7f58618ea7b25a14d5d7a40d7268434 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 14 Jan 2015 17:07:35 +0100 Subject: [PATCH] Throw exception if END_DOCUMENT is seen instead of calling just instantShutdown(). Now we will catch this exception, call notifyConnectionError which also calls instantShutdown() but also notifies the connection listeners of the event. Smack should never all instantShutdown() without notifying the connection listeners. --- .../org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 d1b3ed0eb..3b68ed20c 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 @@ -942,7 +942,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { try { initalOpenStreamSend.checkIfSuccessOrWait(); int eventType = parser.getEventType(); - outerloop: while (!done) { + while (!done) { switch (eventType) { case XmlPullParser.START_TAG: final String name = parser.getName(); @@ -1114,10 +1114,10 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { } break; case XmlPullParser.END_DOCUMENT: - LOGGER.warning("Got END_DOCUMENT, aborting parsing and calling instantShutdown"); - // Use instantShutdown() because we want to keep the stream state if possible - instantShutdown(); - break outerloop; + // END_DOCUMENT only happens in an error case, as otherwise we would see a + // closing stream element before. + throw new SmackException( + "Parser got END_DOCUMENT event. This could happen e.g. if the server closed the connection without sending a closing stream element"); } eventType = parser.next(); }