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/07 13:09:00 UTC

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

    [ 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