[jboss-cvs] JBossAS SVN: r108801 - projects/server-manager/trunk/src/main/java/org/jboss/jbossas/servermanager.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 22 11:52:39 EDT 2010


Author: rachmatowicz at jboss.com
Date: 2010-10-22 11:52:39 -0400 (Fri, 22 Oct 2010)
New Revision: 108801

Modified:
   projects/server-manager/trunk/src/main/java/org/jboss/jbossas/servermanager/Server.java
Log:
Update Server to correctly handle IPv6 URLs (JBAS-8540)

Modified: projects/server-manager/trunk/src/main/java/org/jboss/jbossas/servermanager/Server.java
===================================================================
--- projects/server-manager/trunk/src/main/java/org/jboss/jbossas/servermanager/Server.java	2010-10-22 15:44:09 UTC (rev 108800)
+++ projects/server-manager/trunk/src/main/java/org/jboss/jbossas/servermanager/Server.java	2010-10-22 15:52:39 UTC (rev 108801)
@@ -405,7 +405,7 @@
     */
    public URL getHttpUrl() throws MalformedURLException
    {
-      return new URL("http://" + host + ":" + httpPort);
+      return new URL("http://" + getHostForURL() + ":" + httpPort);
    }
 
    /**
@@ -415,7 +415,7 @@
     */
    public String getRmiUrl()
    {
-      return "jnp://" + host + ":" + rmiPort;
+      return "jnp://" + getHostForURL() + ":" + rmiPort;
    }
 
    /**
@@ -466,6 +466,24 @@
    }
 
    /**
+    * Check host for IPv6 literal address and enclose in square brackets if required.
+    * Used to embed hostnames in URL string to satisfy RFC 2732.
+    * 
+    * @return host suitable for embedding in URL string
+    */
+   private String getHostForURL()
+   {
+      if (host == null)
+    	  return host ;
+      
+      if (host.indexOf(':') != -1) 
+    	  return "[" + host + "]" ;
+      else 
+    	  return host ;
+   }
+   
+   
+   /**
     * Get the httpPort.
     *
     * @return the http port



More information about the jboss-cvs-commits mailing list