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.
This commit is contained in:
Florian Schmaus 2015-01-14 17:07:35 +01:00
parent 9cc58ec8a0
commit 3187436ba7
1 changed files with 5 additions and 5 deletions

View File

@ -942,7 +942,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
try { try {
initalOpenStreamSend.checkIfSuccessOrWait(); initalOpenStreamSend.checkIfSuccessOrWait();
int eventType = parser.getEventType(); int eventType = parser.getEventType();
outerloop: while (!done) { while (!done) {
switch (eventType) { switch (eventType) {
case XmlPullParser.START_TAG: case XmlPullParser.START_TAG:
final String name = parser.getName(); final String name = parser.getName();
@ -1114,10 +1114,10 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
} }
break; break;
case XmlPullParser.END_DOCUMENT: case XmlPullParser.END_DOCUMENT:
LOGGER.warning("Got END_DOCUMENT, aborting parsing and calling instantShutdown"); // END_DOCUMENT only happens in an error case, as otherwise we would see a
// Use instantShutdown() because we want to keep the stream state if possible // closing stream element before.
instantShutdown(); throw new SmackException(
break outerloop; "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(); eventType = parser.next();
} }