Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4142997
Votes 1
Synopsis http:/server.host.com is accepted by new URL( )
Category java:classes_net
Reported Against 1.2.1 , 1.2beta3
Release Fixed
State 11-Closed, Will Not Fix, bug
Priority: 4-Low
Related Bugs 4273176
Submit Date 27-MAY-1998
Description


How come

http:/server.host.com is accepted by:
new URL (String)
without causing an exception

but 

ftp:/server.host.com is not?

Of course neither should be - or am I doing something really stupid here 


Simon
(Review ID: 32279)
======================================================================




/*
The following URL fails to generate a MalformedURLException:

  http:/java.sun.com

Furthermore, the following URL gets "fixed" to the one above, 
which is still wrong:

  http:java.sun.com

Although this bug is presumably cross platform, I only attempted 
to reproduce it under Windows 98.

*/

import java.net.*;

public class UrlBug
{
  public static void main(String[] args)
  {
    URL theUrl;
    String src="";
    try
    {
      src = "http:java.sun.com";
      theUrl = new URL(src);
      System.out.println("URL 1 -- <" + theUrl + ">");

      src = "http:/java.sun.com";
      theUrl = new URL(src);
      System.out.println("URL 2 -- <" + theUrl + ">");

      System.out.println("\nNo MalformedURLException detected");
    }
    catch (MalformedURLException ex)
    {
      System.out.println("Bad URL: " + src);
    }
  }
}
(Review ID: 83633)
======================================================================
Posted Date : 2006-12-07 15:09:15.0
Work Around
N/A
Evaluation
The URL http:/server.host.com has no host part, so the URL it creates has
no host, it points to the file "http://localhost/server.host.com"
  xxxxx@xxxxx   1998-05-27

  xxxxx@xxxxx   2000-03-09

In order to fix this bug, we must enhance the method parseURL() in
URLStreamHandler to throw the MalformedURLException. This enhancement 
is described in an RFE (reference #4273176) and is commited to the
Tiger release of the J2SE. 

I have commited this bug to Tiger and added RFE #4273176 to the
seeAlso field.


  xxxxx@xxxxx   2003-07-09

Decommit from Tiger due to dependencies on RFE #4273176.
Associated RFE will not be implemented due to compatibility issues. See 4273176 for details.
Therefore closing as will not fix.
Posted Date : 2006-12-07 15:09:15.0
Comments
  
  Include a link with my name & email   

Submitted On 28-MAY-1998
Sweaver
Also a URL such as &quot;http://java. sun.com/&quot; is accepted. Should spaces
be allowed? Perhaps there should be a method
String getURLWarning() (or somrthing similar)
which would return a message such as
&quot;Your URL contains spaces. This may cause a problem&quot;
&quot;You have not specified a domain name. This may cause a problem outside
your network&quot;
&quot;You did not specify a protocol. Http:// was assumed&quot;
This would allow a developer to create a URL which would be syntactically
accepted, but
the text in getURLWarning() would be displayed to the user to report any
potential 
problems without actually raising an exception.
A checkURLValid() which goes out to see if the page is actually exists or is
not found,
would be nice too!



PLEASE NOTE: JDK6 is formerly known as Project Mustang