daniel.daugherty@Eng 1999-08-02
The following java programs illustrates the bug:
File repro3a.java:
import java.net.*;
public class repro3a {
public static void main(String[] args) {
try {
//
// According to Section 3.2 of RFC 2396, when '//' is
// used to indicate an authority component, either a
// server or reg_name token must follow.
//
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 authority: http://
System.out.println(e.getMessage());
}
}
}
File repro3b.java:
import java.net.*;
public class repro3b {
public static void main(String[] args) {
try {
//
// According to Section 3.2 of RFC 2396, when '//' is
// used to indicate an authority component, either a
// server or reg_name token must follow. The abs_path
// token (the third slash) can follow the missing server
// or reg_name token.
//
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 authority: http:///
System.out.println(e.getMessage());
}
}
}
The following java programs illustrates the bug:
File repro3a.java:
import java.net.*;
public class repro3a {
public static void main(String[] args) {
try {
//
// According to Section 3.2 of RFC 2396, when '//' is
// used to indicate an authority component, either a
// server or reg_name token must follow.
//
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 authority: http://
System.out.println(e.getMessage());
}
}
}
File repro3b.java:
import java.net.*;
public class repro3b {
public static void main(String[] args) {
try {
//
// According to Section 3.2 of RFC 2396, when '//' is
// used to indicate an authority component, either a
// server or reg_name token must follow. The abs_path
// token (the third slash) can follow the missing server
// or reg_name token.
//
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 authority: http:///
System.out.println(e.getMessage());
}
}
}
- duplicates
-
JDK-4258947 invalid URL (protocol only) not detected by URL() constructor
-
- Closed
-
- relates to
-
JDK-4191994 URLConnection using "mailto:" fails with ESMTP on Sun
-
- Resolved
-