1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-25 21:42:07 +01:00

Make PacketReader.resetParser() throw the exception

there is no need to catch it and disguise it.
This commit is contained in:
Florian Schmaus 2014-04-26 19:08:50 +02:00
parent a613d5f574
commit 790ebeca33

View file

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