From 83c3258dd78ce86d62f3f7309e02631e502085b2 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 19 Jan 2019 11:47:21 +0100 Subject: [PATCH] properly jump out of connection loop on state changing errors --- .../siacs/conversations/xmpp/XmppConnection.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index c42738ff3..d03e9cbe4 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -346,9 +346,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); @@ -359,13 +358,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;