-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b40
-
sparc
-
solaris_7
-
Verified
Name: mtR10145 Date: 01/13/2004
The spec of HttpsURLConnection(URLáurl) states:
Throws: IOException - if the connection can't be established
However, this constructor does not throw IOException for null
argument. Test code below illustrates this bug.
=================== Test24.java =========================
import javax.net.ssl.*;
import java.security.cert.Certificate;
import java.net.URL;
import java.io.IOException;
public class Test24 {
public static void main(String argv[]) {
Test24 test = new Test24();
test.go();
}
public void go() {
try {
HttpsURLConnection c = (HttpsURLConnection) new MyHttpsURLConnection((URL) null);
System.out.println("Error: expected exception not thrown");
} catch (IOException ioe) {
System.out.println("Passed");
} catch (NullPointerException npe) {
System.out.println("Error: unspecified NPE thrown: " + npe);
}
}
class MyHttpsURLConnection extends HttpsURLConnection {
public MyHttpsURLConnection(URL url) throws IOException {
super(url);
}
public String getCipherSuite() {
return new String("");
}
public Certificate[] getLocalCertificates() {
return null;
}
public Certificate[] getServerCertificates() {
return null;
}
public boolean usingProxy() {
return false;
}
public void connect() {
}
public void disconnect() {
}
}
}
=================== output (build 1.5.0-beta-b32 =============
Error: expected exception not thrown
======================================================================
The spec of HttpsURLConnection(URLáurl) states:
Throws: IOException - if the connection can't be established
However, this constructor does not throw IOException for null
argument. Test code below illustrates this bug.
=================== Test24.java =========================
import javax.net.ssl.*;
import java.security.cert.Certificate;
import java.net.URL;
import java.io.IOException;
public class Test24 {
public static void main(String argv[]) {
Test24 test = new Test24();
test.go();
}
public void go() {
try {
HttpsURLConnection c = (HttpsURLConnection) new MyHttpsURLConnection((URL) null);
System.out.println("Error: expected exception not thrown");
} catch (IOException ioe) {
System.out.println("Passed");
} catch (NullPointerException npe) {
System.out.println("Error: unspecified NPE thrown: " + npe);
}
}
class MyHttpsURLConnection extends HttpsURLConnection {
public MyHttpsURLConnection(URL url) throws IOException {
super(url);
}
public String getCipherSuite() {
return new String("");
}
public Certificate[] getLocalCertificates() {
return null;
}
public Certificate[] getServerCertificates() {
return null;
}
public boolean usingProxy() {
return false;
}
public void connect() {
}
public void disconnect() {
}
}
}
=================== output (build 1.5.0-beta-b32 =============
Error: expected exception not thrown
======================================================================