From febee9863f0b3f4003548215cfe404570f6f619c Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 16 Jul 2017 21:02:56 +0200 Subject: [PATCH] catch IllegalArgumentException caused by invalid custom hostname --- .../eu/siacs/conversations/xmpp/XmppConnection.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index c820a1d02..7a6603dd1 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -300,11 +300,9 @@ public class XmppConnection implements Runnable { this.verifiedHostname = account.getHostname(); - InetSocketAddress address = new InetSocketAddress(this.verifiedHostname, account.getPort()); - - features.encryptionEnabled = account.getPort() == 5223; - try { + InetSocketAddress address = new InetSocketAddress(this.verifiedHostname, account.getPort()); + features.encryptionEnabled = address.getPort() == 5223; if (features.encryptionEnabled) { try { final TlsFactoryVerifier tlsFactoryVerifier = getTlsFactoryVerifier(); @@ -317,14 +315,13 @@ public class XmppConnection implements Runnable { throw new StateChangingException(Account.State.TLS_ERROR); } } catch (KeyManagementException e) { - features.encryptionEnabled = false; - localSocket = new Socket(); + throw new StateChangingException(Account.State.TLS_ERROR); } } else { localSocket = new Socket(); localSocket.connect(address, Config.SOCKET_TIMEOUT * 1000); } - } catch (IOException e) { + } catch (IOException | IllegalArgumentException e) { throw new UnknownHostException(); } try {