diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-01-25 23:37:12 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-01-25 23:37:12 +0100 |
commit | 158bb45fe48cf0e779f626e562c93400d9b41eff (patch) | |
tree | 914e7498433014f1c38c2783853eedb425a22496 | |
parent | df61e140b689b4455ac5461b68291f8507735330 (diff) |
properly jump out of connection loop on state changing errors
-rw-r--r-- | src/main/java/de/pixart/messenger/xmpp/XmppConnection.java | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java index c56410d77..705a3178d 100644 --- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java +++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java @@ -372,9 +372,8 @@ public class XmppConnection implements Runnable { if (!tlsFactoryVerifier.verifier.verify(account.getServer(), verifiedHostname, ((SSLSocket) localSocket).getSession())) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": TLS certificate verification failed"); - if (!iterator.hasNext()) { - throw new StateChangingException(Account.State.TLS_ERROR); - } + FileBackend.close(localSocket); + throw new StateChangingException(Account.State.TLS_ERROR); } } localSocket.setSoTimeout(Config.SOCKET_TIMEOUT * 1000); @@ -385,13 +384,13 @@ public class XmppConnection implements Runnable { } break; // successfully connected to server that speaks xmpp } else { - localSocket.close(); - if (!iterator.hasNext()) { - throw new StateChangingException(Account.State.STREAM_OPENING_ERROR); - } + FileBackend.close(localSocket); + throw new StateChangingException(Account.State.STREAM_OPENING_ERROR); } } catch (final StateChangingException e) { - throw e; + if (!iterator.hasNext()) { + throw e; + } } catch (InterruptedException e) { Log.d(Config.LOGTAG,account.getJid().asBareJid()+": thread was interrupted before beginning stream"); return; |