FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
If ProxySelector is set to null then it appears that no effort is made to get an http connection in HttpURLConnection.plainConnect(...). This results in a null pointer exception when the method attempts to get the http outputstream.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See attached source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
make a direct connection when ProxySelector = null
ACTUAL -
Null Pointer Exception
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:773)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:661)
at HTTPTest.main(HTTPTest.java:15)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.net.ProxySelector;
import java.net.URLConnection;
import java.net.URL;
public class HTTPTest {
public static void main(String[] args) throws Exception {
ProxySelector.setDefault(null);
String url = "http://java.sun.com/";
URL location = new URL(url);
URLConnection con = null;
con = location.openConnection();
try {
con.connect();
} catch (NullPointerException ex) {
ex.printStackTrace();
}
}
}
---------- END SOURCE ----------
###@###.### 2005-1-10 23:40:19 GMT
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
If ProxySelector is set to null then it appears that no effort is made to get an http connection in HttpURLConnection.plainConnect(...). This results in a null pointer exception when the method attempts to get the http outputstream.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See attached source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
make a direct connection when ProxySelector = null
ACTUAL -
Null Pointer Exception
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:773)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:661)
at HTTPTest.main(HTTPTest.java:15)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.net.ProxySelector;
import java.net.URLConnection;
import java.net.URL;
public class HTTPTest {
public static void main(String[] args) throws Exception {
ProxySelector.setDefault(null);
String url = "http://java.sun.com/";
URL location = new URL(url);
URLConnection con = null;
con = location.openConnection();
try {
con.connect();
} catch (NullPointerException ex) {
ex.printStackTrace();
}
}
}
---------- END SOURCE ----------
###@###.### 2005-1-10 23:40:19 GMT
- duplicates
-
JDK-6339079 Slow Socket(ipaddress, port) URLConnection.openConnection NPE
-
- Closed
-