diff --git a/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java b/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java index 2ce999d9ad..152ae34ce3 100644 --- a/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java +++ b/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java @@ -217,7 +217,11 @@ public static void updateConnectionProperties(Properties connectionProperties, I String address = addr.getHostAddress(); Object old = connectionProperties.put(TeiidURL.CONNECTION.CLIENT_IP_ADDRESS, address); if (old == null || !address.equals(old)) { - connectionProperties.put(TeiidURL.CONNECTION.CLIENT_HOSTNAME, addr.getCanonicalHostName()); + if (addr.isLoopbackAddress()) { + connectionProperties.put(TeiidURL.CONNECTION.CLIENT_HOSTNAME, addr.getCanonicalHostName()); + } else { + connectionProperties.put(TeiidURL.CONNECTION.CLIENT_HOSTNAME, "localhost"); //$NON-NLS-1$ + } if (setMac) { try { NetworkInterface ni = NetworkInterface.getByInetAddress(addr); diff --git a/runtime/src/test/java/org/teiid/transport/TestCommSockets.java b/runtime/src/test/java/org/teiid/transport/TestCommSockets.java index fcaa97de06..38e9d988dd 100644 --- a/runtime/src/test/java/org/teiid/transport/TestCommSockets.java +++ b/runtime/src/test/java/org/teiid/transport/TestCommSockets.java @@ -30,6 +30,10 @@ import java.net.InetSocketAddress; import java.util.Arrays; import java.util.Properties; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLContext; @@ -359,20 +363,32 @@ private void helpTestNewInstance(Properties p) helpEstablishConnection(true, config, p); } - @Test(timeout=19000) public void testAutoFailoverPing() throws Exception { + @Test public void testAutoFailoverPing() throws Exception { Properties p = new Properties(); p.setProperty(TeiidURL.CONNECTION.AUTO_FAILOVER, "true"); p.setProperty("org.teiid.sockets.synchronousttl", "20000"); SocketServerConnection conn = helpEstablishConnection(false, new SSLConfiguration(), p); - final FakeService fs = conn.getService(FakeService.class); - ResultsFuture future = fs.delayedAsynchResult(); - future.addCompletionListener(new CompletionListener() { + ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(); + Future future = exec.submit(new Runnable() { + @Override - public void onCompletion(ResultsFuture future) { - fs.asynchResult(); //potentially recurrent; + public void run() { + final FakeService fs = conn.getService(FakeService.class); + ResultsFuture f = fs.delayedAsynchResult(); + f.addCompletionListener(new CompletionListener() { + @Override + public void onCompletion(ResultsFuture future) { + fs.asynchResult(); //potentially recurrent; + } + }); + try { + f.get(); + } catch (Exception e) { + throw new RuntimeException(e); + } } }); - future.get(); + future.get(19, TimeUnit.SECONDS); } }