Author: richard.opalka(a)jboss.com
Date: 2010-12-13 07:55:12 -0500 (Mon, 13 Dec 2010)
New Revision: 13469
Modified:
common/branches/jbossws-common-1.4.1/src/main/java/org/jboss/wsf/common/management/AbstractServerConfig.java
common/branches/jbossws-common-1.4.1/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java
Log:
[JBWS-3139] IPv6 addresses have to be surrounded with '[' & ']' in
URLs - see RFC2732
Modified:
common/branches/jbossws-common-1.4.1/src/main/java/org/jboss/wsf/common/management/AbstractServerConfig.java
===================================================================
---
common/branches/jbossws-common-1.4.1/src/main/java/org/jboss/wsf/common/management/AbstractServerConfig.java 2010-12-13
12:53:04 UTC (rev 13468)
+++
common/branches/jbossws-common-1.4.1/src/main/java/org/jboss/wsf/common/management/AbstractServerConfig.java 2010-12-13
12:55:12 UTC (rev 13469)
@@ -21,6 +21,7 @@
*/
package org.jboss.wsf.common.management;
+import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Set;
@@ -97,9 +98,17 @@
log.debug("Using local host: " + localHost.getHostName());
host = localHost.getHostName();
}
- this.webServiceHost = "127.0.0.1".equals(host) ? "localhost" :
host; // TCK workaround
+ this.webServiceHost = toIPv6URLFormat("127.0.0.1".equals(host) ?
"localhost" : host); // TCK workaround
}
+ private String toIPv6URLFormat(final String host) throws UnknownHostException
+ {
+ final boolean isIPv6Address = !UNDEFINED_HOSTNAME.equals(host) &&
InetAddress.getByName(host) instanceof Inet6Address;
+ final boolean isIPv6Formatted = isIPv6Address &&
host.startsWith("[");
+
+ return isIPv6Address && !isIPv6Formatted ? "[" + host +
"]" : host;
+ }
+
public void setWebServicePort(int port)
{
this.webServicePort = port;
Modified:
common/branches/jbossws-common-1.4.1/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java
===================================================================
---
common/branches/jbossws-common-1.4.1/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java 2010-12-13
12:53:04 UTC (rev 13468)
+++
common/branches/jbossws-common-1.4.1/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java 2010-12-13
12:55:12 UTC (rev 13469)
@@ -22,8 +22,11 @@
package org.jboss.wsf.test;
import java.io.File;
+import java.net.Inet6Address;
+import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.UnknownHostException;
import java.util.Hashtable;
import javax.management.MBeanServerConnection;
@@ -180,8 +183,23 @@
*/
public static String getServerHost()
{
- return System.getProperty(SYSPROP_JBOSS_BIND_ADDRESS, "localhost");
+ final String host = System.getProperty(SYSPROP_JBOSS_BIND_ADDRESS,
"localhost");
+ return toIPv6URLFormat(host);
}
+
+ private static String toIPv6URLFormat(final String host)
+ {
+ try
+ {
+ final boolean isIPv6Address = InetAddress.getByName(host) instanceof
Inet6Address;
+ final boolean isIPv6Formatted = isIPv6Address &&
host.startsWith("[");
+ return isIPv6Address && !isIPv6Formatted ? "[" + host +
"]" : host;
+ }
+ catch (final UnknownHostException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
@SuppressWarnings("unchecked")
public static MBeanServerConnection getServer()
Show replies by date