activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1147812 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java
Date Mon, 18 Jul 2011 11:16:31 GMT
Author: dejanb
Date: Mon Jul 18 11:16:31 2011
New Revision: 1147812

URL: http://svn.apache.org/viewvc?rev=1147812&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3135 - TcpTransport.getRemoteAddress() better formatting

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java?rev=1147812&r1=1147811&r2=1147812&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java
Mon Jul 18 11:16:31 2011
@@ -20,13 +20,7 @@ import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.InterruptedIOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import java.net.URI;
-import java.net.UnknownHostException;
+import java.net.*;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.CountDownLatch;
@@ -618,7 +612,12 @@ public class TcpTransport extends Transp
 
     public String getRemoteAddress() {
         if (socket != null) {
-            return "" + socket.getRemoteSocketAddress();
+            SocketAddress address = socket.getRemoteSocketAddress();
+            if (address instanceof InetSocketAddress) {
+                return "tcp://" + ((InetSocketAddress)address).getAddress().getHostAddress()
+ ":" + ((InetSocketAddress)address).getPort();
+            } else {
+                return "" + socket.getRemoteSocketAddress();
+            }
         }
         return null;
     }



Mime
View raw message