When we dont give colon before port no , then it doesnt give port no in getPort() and it doesnt even give any exception. Its coming with merlin build 71 on Solaris 8.
How to reproduce this:
----------------------
URL u4 = new URL("http://[javasoft.eng.sun.com]9999/path1/path2/");
System.out.println("ToString u4 : " + u4.toString());
System.out.println("Authority : " + u4.getAuthority());
System.out.println("File : " + u4.getFile());
System.out.println("Host : " + u4.getHost());
System.out.println("Path : " + u4.getPath());
System.out.println("Port : " + u4.getPort());
System.out.println("DefaultPort : " + u4.getDefaultPort());
System.out.println("Query : " + u4.getQuery());
System.out.println("Protocol : " + u4.getProtocol());
System.out.println("Reference : " + u4.getRef());
System.out.println("ToString : " + u4.toString());
System.out.println("Toexternal form : " + u4.toExternalForm());
Output:
ToString u4 : http://[javasoft.eng.sun.com]9999/path1/path2/
Authority : [javasoft.eng.sun.com]9999
File : /path1/path2/
Host : [javasoft.eng.sun.com]
Path : /path1/path2/
Port : -1
DefaultPort : 80
Query : null
Protocol : http
Reference : null
How to reproduce this:
----------------------
URL u4 = new URL("http://[javasoft.eng.sun.com]9999/path1/path2/");
System.out.println("ToString u4 : " + u4.toString());
System.out.println("Authority : " + u4.getAuthority());
System.out.println("File : " + u4.getFile());
System.out.println("Host : " + u4.getHost());
System.out.println("Path : " + u4.getPath());
System.out.println("Port : " + u4.getPort());
System.out.println("DefaultPort : " + u4.getDefaultPort());
System.out.println("Query : " + u4.getQuery());
System.out.println("Protocol : " + u4.getProtocol());
System.out.println("Reference : " + u4.getRef());
System.out.println("ToString : " + u4.toString());
System.out.println("Toexternal form : " + u4.toExternalForm());
Output:
ToString u4 : http://[javasoft.eng.sun.com]9999/path1/path2/
Authority : [javasoft.eng.sun.com]9999
File : /path1/path2/
Host : [javasoft.eng.sun.com]
Path : /path1/path2/
Port : -1
DefaultPort : 80
Query : null
Protocol : http
Reference : null