From fe258fe1105c96042cdba11104e7ad21aaf8ca51 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 21 Jul 2014 16:37:31 +0200 Subject: [PATCH] Fix XMPPTCPConnection to set 'host' and 'port' Fixes SMACK-585 --- .../org/jivesoftware/smack/AbstractXMPPConnection.java | 4 ++-- .../java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index f6ea8666c..dea05c0a7 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -202,12 +202,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { /** * The used host to establish the connection to */ - private String host; + protected String host; /** * The used port to establish the connection to */ - private int port; + protected int port; /** * Set to true if the server requires the connection to be binded in order to continue. diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index baf2e2181..4a0201d4a 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -416,7 +416,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { } private void connectUsingConfiguration(ConnectionConfiguration config) throws SmackException, IOException { - Exception exception = null; try { maybeResolveDns(); } @@ -426,7 +425,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { Iterator it = config.getHostAddresses().iterator(); List failedAddresses = new LinkedList(); while (it.hasNext()) { - exception = null; + Exception exception = null; HostAddress hostAddress = it.next(); String host = hostAddress.getFQDN(); int port = hostAddress.getPort(); @@ -442,8 +441,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { } if (exception == null) { // We found a host to connect to, break here - host = hostAddress.getFQDN(); - port = hostAddress.getPort(); + this.host = host; + this.port = port; break; } hostAddress.setException(exception);