You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by "Svetlana Samoilenko (JIRA)" <ji...@apache.org> on 2006/02/01 06:00:32 UTC

[jira] Created: (HARMONY-60) java.net.URL.getHost() must return the IPv6 address enclosed in square brackets

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


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


[jira] Assigned: (HARMONY-60) java.net.URL.getHost() must return the IPv6 address enclosed in square brackets

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-60?page=all ]

Tim Ellison reassigned HARMONY-60:
----------------------------------

    Assign To: Tim Ellison

> 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


[jira] Commented: (HARMONY-60) java.net.URL.getHost() must return the IPv6 address enclosed in square brackets

Posted by "Svetlana Samoilenko (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-60?page=comments#action_12365424 ] 

Svetlana Samoilenko commented on HARMONY-60:
--------------------------------------------

Tim, 
I used revision 375380 and the IP6 address in [ ] now. 
Test output is: 
**OK, host is in square brackets=[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]

Actually, it is BEA bug, they assume that,  for example, "http://google.com/" is a IPV6 address, presumably because it contains ':'.
it is just incorrect host address, but URL should not complain unlike URI. 
It would be better to check that it is real correct IP6 address, but may be we should copy all BEA bugs for compatibility ;) ?



> 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


[jira] Closed: (HARMONY-60) java.net.URL.getHost() must return the IPv6 address enclosed in square brackets

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-60?page=all ]
     
Tim Ellison closed HARMONY-60:
------------------------------


Verified by Svetlana.

I agree that behavior is likely unintentional -- but harmony now does the same thing (hopefully nobody would rely on that, and if it is fixed in the reference our regression test will find it now).

> 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


[jira] Resolved: (HARMONY-60) java.net.URL.getHost() must return the IPv6 address enclosed in square brackets

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ 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