From 790ebeca3380ed23297df3ee2ec3108d18ec3851 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 26 Apr 2014 19:08:50 +0200 Subject: [PATCH] Make PacketReader.resetParser() throw the exception there is no need to catch it and disguise it. --- .../org/jivesoftware/smack/PacketReader.java | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tcp/src/main/java/org/jivesoftware/smack/PacketReader.java b/tcp/src/main/java/org/jivesoftware/smack/PacketReader.java index da76b382f..3b57754e4 100644 --- a/tcp/src/main/java/org/jivesoftware/smack/PacketReader.java +++ b/tcp/src/main/java/org/jivesoftware/smack/PacketReader.java @@ -34,9 +34,6 @@ import org.xmlpull.v1.XmlPullParserFactory; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; -import java.util.logging.Level; -import java.util.logging.Logger; - /** * Listens for XML traffic from the XMPP server and parses it into packet objects. * The packet reader also invokes all packet listeners and collectors.

@@ -47,8 +44,6 @@ import java.util.logging.Logger; */ class PacketReader { - private static final Logger LOGGER = Logger.getLogger(PacketReader.class.getName()); - private Thread readerThread; private XMPPTCPConnection connection; @@ -64,7 +59,7 @@ class PacketReader { volatile boolean done; - protected PacketReader(final XMPPTCPConnection connection) { + protected PacketReader(final XMPPTCPConnection connection) throws XmlPullParserException { this.connection = connection; this.init(); } @@ -72,8 +67,10 @@ class PacketReader { /** * Initializes the reader in order to be used. The reader is initialized during the * first connection and when reconnecting due to an abruptly disconnection. + * + * @throws XmlPullParserException if the parser could not be reset. */ - protected void init() { + protected void init() throws XmlPullParserException { done = false; lastFeaturesParsed = false; @@ -130,16 +127,13 @@ class PacketReader { * Resets the parser using the latest connection's reader. Reseting the parser is necessary * when the plain connection has been secured or when a new opening stream element is going * to be sent by the server. + * + * @throws XmlPullParserException XmlPullParserException if the parser could not be reset. */ - private void resetParser() { - try { - parser = XmlPullParserFactory.newInstance().newPullParser(); - parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); - parser.setInput(connection.reader); - } - catch (XmlPullParserException xppe) { - LOGGER.log(Level.WARNING, "Error while resetting parser", xppe); - } + private void resetParser() throws XmlPullParserException { + parser = XmlPullParserFactory.newInstance().newPullParser(); + parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); + parser.setInput(connection.reader); } /**