harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Ellison (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (HARMONY-60) java.net.URL.getHost() must return the IPv6 address enclosed in square brackets
Date Mon, 06 Feb 2006 21:35:58 GMT
     [ http://issues.apache.org/jira/browse/HARMONY-60?page=all ]
     
Tim Ellison resolved HARMONY-60:
--------------------------------

    Resolution: Fixed

Svetlana,

Fixed in LUNI java.net.URL at repo revision 375380.

When testing on the reference implementation it appears that any host containing a ':' character
(e.g. new URL("http", "www.apache.org:8080", "resource")) gets wrappered in square brackets,
which seems odd -- however, to retain compatibility the fix replicates this behavior.

Please check that this fully resolves your problem.


> java.net.URL.getHost() must return the IPv6 address enclosed in square brackets
> -------------------------------------------------------------------------------
>
>          Key: HARMONY-60
>          URL: http://issues.apache.org/jira/browse/HARMONY-60
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>     Assignee: Tim Ellison

>
> According to j2se 1.4.2 specification for java.net.URL.getHost() the method must return
 the IPv6 address enclosed in square brackets ('[' and ']'). The test listed below shows an
absence of square brackets for the IPv6 address.
> Code to reproduce: 
> import java.net.*; 
> public class test2  {
>     public static void main(String[] args) {
>        
>      URL url=null; 
>      String protocol = "http";
>      int port = -1; 
>      String host = "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210";
>      String file = "myFile";
>     
>      try {
>             url = new URL(protocol,host,port,file); 
>      } catch (Exception e) {
>             System.out.println("URL.URL(protocol,host,port,file) caused:" + e); 
>             return; 
>      }
>      if (url.getHost().equals("["+host+"]")) {
>            System.out.println("OK, host is in square brackets="+url.getHost());
>      } else {
>            System.out.println("Incorrect, host is not in square brackets="+url.getHost());
>      }
>   }
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2 
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> java version "1.4.2_04" 
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) 
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native
Threads, GC strategy: parallel) 
> ***OK, host is in square brackets=[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable.
> ***Incorrect, host is not in square brackets=FEDC:BA98:7654:3210:FEDC:BA98:7654:3210
> Suggested junit test case:
> ------------------------ URLTest.java -------------------------------------------------

> import java.net.*; 
> import junit.framework.*; 
> public class URLTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(URLTest.class); 
>     } 
>     public void test_getHost() { 
>         URL url=null; 
>         String protocol = "http";
>         int port = -1; 
>         String host = "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210";
>         String file = "myFile";
>     
>         try {
>             url = new URL(protocol,host,port,file); 
>         } catch (Exception e) {
>             fail("Assert 0: URL.URL(protocol,host,port,file) caused:" + e); 
>         }
>        assertEquals (("["+host+"]"), url.getHost());
>    } 
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message