daniel.daugherty@Eng 1999-08-02
The following java program illustrates the bug:
File repro2.java:
import java.net.*;
public class repro2 {
public static void main(String[] args) {
try {
//
// According to Section 3 of RFC 2396, the scheme and colon
// must be followed by a scheme specific component. While
// some protocols may allow an empty scheme specific
// component, the http protocol does not.
//
URL url = new URL("http:");
System.err.println("Test FAILed:"
+ " URL constructor did not throw exception.");
} catch (MalformedURLException e) {
System.out.println("Test PASSed: URL constructor threw exception.");
// Expect MalformedURLException: no protocol: http:
System.out.println(e.getMessage());
}
}
}
The following java program illustrates the bug:
File repro2.java:
import java.net.*;
public class repro2 {
public static void main(String[] args) {
try {
//
// According to Section 3 of RFC 2396, the scheme and colon
// must be followed by a scheme specific component. While
// some protocols may allow an empty scheme specific
// component, the http protocol does not.
//
URL url = new URL("http:");
System.err.println("Test FAILed:"
+ " URL constructor did not throw exception.");
} catch (MalformedURLException e) {
System.out.println("Test PASSed: URL constructor threw exception.");
// Expect MalformedURLException: no protocol: http:
System.out.println(e.getMessage());
}
}
}
- duplicates
-
JDK-4258949 invalid URL (no authority component) not detected by URL() constructor
-
- Closed
-
- relates to
-
JDK-4191994 URLConnection using "mailto:" fails with ESMTP on Sun
-
- Resolved
-