From 5f9c342f7edfcc7094c70a2d5f88b470a0362871 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 21 Oct 2014 23:43:11 +0200 Subject: [PATCH] Don't check for END_DOCUMENT parsePackets() instead use the event switch/case and log a warning if this ever happens, as it's likely a programming error. --- .../java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 09fff0b3c..95a95fa7a 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 @@ -1010,7 +1010,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { try { initalOpenStreamSend.checkIfSuccessOrWait(); int eventType = parser.getEventType(); - while (!done && eventType != XmlPullParser.END_DOCUMENT) { + while (!done) { switch (eventType) { case XmlPullParser.START_TAG: final String name = parser.getName(); @@ -1207,6 +1207,11 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { disconnect(); } break; + case XmlPullParser.END_DOCUMENT: + // This should not happen, log a warning and disconnect() + LOGGER.warning("Got END_DOCUMENT, aborting parsing"); + disconnect(); + break; } eventType = parser.next(); }