[jboss-cvs] JBossAS SVN: r75662 - trunk/cluster/src/main/org/jboss/ha/framework/server.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jul 10 23:07:09 EDT 2008


Author: bstansberry at jboss.com
Date: 2008-07-10 23:07:09 -0400 (Thu, 10 Jul 2008)
New Revision: 75662

Modified:
   trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterNodeImpl.java
Log:
[JBAS-3794] Fix getFastHostName

Modified: trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterNodeImpl.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterNodeImpl.java	2008-07-11 02:35:22 UTC (rev 75661)
+++ trunk/cluster/src/main/org/jboss/ha/framework/server/ClusterNodeImpl.java	2008-07-11 03:07:09 UTC (rev 75662)
@@ -22,6 +22,7 @@
 package org.jboss.ha.framework.server;
 
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 
 import org.jboss.ha.framework.interfaces.ClusterNode;
 import org.jgroups.stack.IpAddress;
@@ -169,28 +170,30 @@
     * If the symbolic name cannot be determined from InetAddress.toString(),
     * the value of {@link InetAddress.getHostAddress()} is returned.
     */
-   private String getFastHostName(InetAddress address)
+   private static String getFastHostName(InetAddress address)
    {
       String result = null;
       
+      String hostAddress = address.getHostAddress();
+      
       String inetAddr = address.toString();
-      int idx = inetAddr.indexOf(address.getHostAddress());
-      int idx1 = inetAddr.lastIndexOf('/');
+      int idx = inetAddr.lastIndexOf('/');
+      int idx1 = inetAddr.indexOf(hostAddress);
       if (idx1 == idx + 1)
       {
-         if (idx1 == 0)
-            result = address.getHostAddress();
+         if (idx == 0)
+            result = hostAddress;
          else
-            result = inetAddr.substring(0, idx1);
+            result = inetAddr.substring(0, idx);
       }
       else
       {
          // Doesn't follow the toString() contract!
-         result = address.getHostAddress();
+         result = hostAddress;
       }
       return result;
    }
    
    // Inner classes -------------------------------------------------
-
+   
 }




More information about the jboss-cvs-commits mailing list