FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
Calling getResponseCode() on an HTTP connection for a particular URL throws IllegalArgumentException apparently based on an invalid HTTP protocol response while trying to follow a redirect. A protocol error should not throw an unchecked exception.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The enclosed test program demonstates the problem at this time. It depends upon the behavior of a particular web server, so it may not demonstrate the problem in the future.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Either a response code should be printed or a checked exception should be printed.
ACTUAL -
An IllegalArgumentException is printed.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Caused by: java.lang.IllegalArgumentException: protocol = http host = null
at sun.net.spi.DefaultProxySelector.select(DefaultProxySelector.java:176)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1132)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1032)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:966)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect0(HttpURLConnection.java:2701)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:2623)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1806)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
REPRODUCIBILITY :
This bug can be reproduced always.
Test cases inJDK-6563286 and JDK-6797318 show the same issue.
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
Calling getResponseCode() on an HTTP connection for a particular URL throws IllegalArgumentException apparently based on an invalid HTTP protocol response while trying to follow a redirect. A protocol error should not throw an unchecked exception.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The enclosed test program demonstates the problem at this time. It depends upon the behavior of a particular web server, so it may not demonstrate the problem in the future.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Either a response code should be printed or a checked exception should be printed.
ACTUAL -
An IllegalArgumentException is printed.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Caused by: java.lang.IllegalArgumentException: protocol = http host = null
at sun.net.spi.DefaultProxySelector.select(DefaultProxySelector.java:176)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1132)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1032)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:966)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect0(HttpURLConnection.java:2701)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:2623)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1806)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
REPRODUCIBILITY :
This bug can be reproduced always.
Test cases in
- csr for
-
JDK-8230044 getResponseCode() throws IllegalArgumentException caused by protocol error while following redirect
-
- Closed
-
- duplicates
-
JDK-8230220 java/net/HttpURLConnection/HttpURLProxySelectionTest.java fails intermittently
-
- Resolved
-