Don't throw XmlPullParserException

removes the need to wrap the exception in a SmackException in
XMPPTCPConnection.initConnection()
This commit is contained in:
Florian Schmaus 2014-04-28 17:35:07 +02:00
parent 06c6546d2e
commit ddb47c2d60
2 changed files with 15 additions and 10 deletions

View File

@ -59,7 +59,7 @@ class PacketReader {
volatile boolean done;
protected PacketReader(final XMPPTCPConnection connection) throws XmlPullParserException {
protected PacketReader(final XMPPTCPConnection connection) throws SmackException {
this.connection = connection;
this.init();
}
@ -68,9 +68,9 @@ 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.
* @throws SmackException if the parser could not be reset.
*/
protected void init() throws XmlPullParserException {
protected void init() throws SmackException {
done = false;
lastFeaturesParsed = false;
@ -128,12 +128,17 @@ class PacketReader {
* 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.
* @throws SmackException if the parser could not be reset.
*/
private void resetParser() throws XmlPullParserException {
parser = XmlPullParserFactory.newInstance().newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(connection.reader);
private void resetParser() throws SmackException {
try {
parser = XmlPullParserFactory.newInstance().newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(connection.reader);
}
catch (XmlPullParserException e) {
throw new SmackException(e);
}
}
/**

View File

@ -518,7 +518,7 @@ public class XMPPTCPConnection extends XMPPConnection {
}
}
catch (Exception ex) {
catch (SmackException ex) {
// An exception occurred in setting up the connection. Make sure we shut down the
// readers and writers and close the socket.
@ -561,7 +561,7 @@ public class XMPPTCPConnection extends XMPPConnection {
authenticated = false;
connected = false;
throw new SmackException(ex); // Everything stoppped. Now throw the exception.
throw ex; // Everything stoppped. Now throw the exception.
}
}