You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2014/08/02 12:47:34 UTC

svn commit: r1606543 - in /commons/proper/jcs/trunk: commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/ commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/ src/changes/

Author: sebb
Date: Sun Jun 29 17:44:58 2014
New Revision: 1606543

URL: http://svn.apache.org/r1606543
Log:
JCS-133 RemoteUtils.getNamingURL does not handle IPv6 numeric addresses properly
Fix could be improved; check if it helps the Jenkins build

Modified:
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java
    commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtilsUnitTest.java
    commons/proper/jcs/trunk/src/changes/changes.xml

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java?rev=1606543&r1=1606542&r2=1606543&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java Sun Jun 29 17:44:58 2014
@@ -215,6 +215,9 @@ public class RemoteUtils
      */
     public static String getNamingURL(final String registryHost, final int registryPort, final String serviceName)
     {
+        if (registryHost.contains(":")) { // TODO improve this check? See also JCS-133
+            return "//[" + registryHost.replaceFirst("%", "%25") + "]:" + registryPort + "/" + serviceName;
+        }
         final String registryURL = "//" + registryHost + ":" + registryPort + "/" + serviceName;
         return registryURL;
     }

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtilsUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtilsUnitTest.java?rev=1606543&r1=1606542&r2=1606543&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtilsUnitTest.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtilsUnitTest.java Sun Jun 29 17:44:58 2014
@@ -41,4 +41,11 @@ public class RemoteUtilsUnitTest
         Registry registry = RemoteUtils.createRegistry( 1102 );
         assertNotNull("Registry should not be null", registry);
     }
+
+    public void testgetNamingURL()
+    {
+        assertEquals("//host:1/servicename", RemoteUtils.getNamingURL("host",1,"servicename"));
+        assertEquals("//127.0.0.1:2/servicename", RemoteUtils.getNamingURL("127.0.0.1",2,"servicename"));
+        assertEquals("//[0:0:0:0:0:0:0:1%251]:3/servicename", RemoteUtils.getNamingURL("0:0:0:0:0:0:0:1%1",3,"servicename"));
+    }
 }

Modified: commons/proper/jcs/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/changes/changes.xml?rev=1606543&r1=1606542&r2=1606543&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/changes/changes.xml (original)
+++ commons/proper/jcs/trunk/src/changes/changes.xml Sun Jun 29 17:44:58 2014
@@ -20,6 +20,9 @@
 	</properties>
 	<body>
 		<release version="2.0" date="unreleased" description="JDK 1.6 based major release">
+            <action issue="JCS-133" dev="seb" type="fix">
+                RemoteUtils.getNamingURL does not handle IPv6 numeric addresses properly
+            </action>
             <action issue="JCS-131" dev="tv" type="remove">
                 Remove KeyGeneratorUtil and AddressUtil as they are not used
             </action>