activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r750532 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/transport/tcp/ test/java/org/apache/activemq/transport/tcp/ test/resources/org/apache/activemq/transport/tcp/
Date Thu, 05 Mar 2009 18:16:15 GMT
Author: gtully
Date: Thu Mar  5 18:16:13 2009
New Revision: 750532

URL: http://svn.apache.org/viewvc?rev=750532&view=rev
Log:
AMQ-2094. fix break of org.apache.activemq.transport.tcp.SslContextNBrokerServiceTest where
localhost and host name resolve to different interfaces as now the broker just listens on
one interface unless ip:0.0.0.0 is used. The connectorUri did nore reflect the socket

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportServer.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/SslContextNBrokerServiceTest.java
    activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/tcp/n-brokers-ssl.xml

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportServer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportServer.java?rev=750532&r1=750531&r2=750532&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportServer.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportServer.java
Thu Mar  5 18:16:13 2009
@@ -138,7 +138,7 @@
             throw IOExceptionSupport.create("Failed to bind to server socket: " + bind +
" due to: " + e, e);
         }
         try {
-            setConnectURI(new URI(bind.getScheme(), bind.getUserInfo(), resolveHostName(bind.getHost()),
serverSocket.getLocalPort(), bind.getPath(), bind.getQuery(), bind
+            setConnectURI(new URI(bind.getScheme(), bind.getUserInfo(), resolveHostName(serverSocket,
addr), serverSocket.getLocalPort(), bind.getPath(), bind.getQuery(), bind
                 .getFragment()));
         } catch (URISyntaxException e) {
 
@@ -314,15 +314,22 @@
     }
 
     /**
-     * @param hostName
+     * @param socket 
+     * @param inetAddress
      * @return real hostName
      * @throws UnknownHostException
      */
-    protected String resolveHostName(String hostName) throws UnknownHostException {
-        String result = hostName;
-        // hostname can be null for vm:// protocol ...
-        if (hostName != null && (hostName.equalsIgnoreCase("localhost") || hostName.equals("127.0.0.1")))
{
-            result = InetAddress.getLocalHost().getHostName();
+    protected String resolveHostName(ServerSocket socket, InetAddress bindAddress) throws
UnknownHostException {
+        String result = null;
+        if (socket.isBound()) {
+            if (socket.getInetAddress().isAnyLocalAddress()) {
+                // make it more human readable and useful, an alternative to 0.0.0.0
+                result = InetAddress.getLocalHost().getHostName();
+            } else {
+                result = socket.getInetAddress().getCanonicalHostName();
+            }
+        } else {
+            result = bindAddress.getCanonicalHostName();
         }
         return result;
     }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/SslContextNBrokerServiceTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/SslContextNBrokerServiceTest.java?rev=750532&r1=750531&r2=750532&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/SslContextNBrokerServiceTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/SslContextNBrokerServiceTest.java
Thu Mar  5 18:16:13 2009
@@ -71,6 +71,8 @@
         context.init(null, new TrustManager[] {catcher}, null);
         
         SSLSocketFactory factory = context.getSocketFactory();
+        LOG.info("Connecting to broker: " + broker.getBrokerName()
+                + " on: " + brokerUri.getHost() + ":" + brokerUri.getPort());
         SSLSocket socket = (SSLSocket)factory.createSocket(brokerUri.getHost(), brokerUri.getPort());
         socket.setSoTimeout(5000);
         socket.startHandshake();

Modified: activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/tcp/n-brokers-ssl.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/tcp/n-brokers-ssl.xml?rev=750532&r1=750531&r2=750532&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/tcp/n-brokers-ssl.xml
(original)
+++ activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/tcp/n-brokers-ssl.xml
Thu Mar  5 18:16:13 2009
@@ -31,7 +31,7 @@
     </amq:sslContext>
     
     <amq:transportConnectors>
-      <amq:transportConnector uri="ssl://localhost:62616" />
+      <amq:transportConnector uri="ssl://0.0.0.0:62616" />
     </amq:transportConnectors>
     
   </amq:broker>



Mime
View raw message