-
Bug
-
Resolution: Fixed
-
P4
-
None
-
9
-
generic
-
windows
FULL PRODUCT VERSION :
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 10.0.15063]
A DESCRIPTION OF THE PROBLEM :
When sending an HTTP request using the new HttpClient, an UnsupportedOperationException is thrown when the response headers contain double quotes.
The exception is thrown when trying to parse the following header (note the double quotes around "set-cookie"):
cache-control: max-age=0, no-cache, s-maxage=10, no-cache="set-cookie"
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Send a GET request for which the response headers will contain double quotes using the new HttpClient (for example: GET "https://www.pluralsight.com").
Please check the source code for a complete example.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The headers are parsed correctly and no exception is thrown.
ACTUAL -
java.lang.UnsupportedOperationException is thrown.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.UnsupportedOperationException
at java.base/java.util.Collections$UnmodifiableCollection.addAll(Collections.java:1066)
at jdk.incubator.httpclient/jdk.incubator.http.ResponseHeaders.lambda$parse$1(ResponseHeaders.java:162)
at java.base/java.util.HashMap.merge(HashMap.java:1301)
at jdk.incubator.httpclient/jdk.incubator.http.ResponseHeaders.parse(ResponseHeaders.java:155)
at jdk.incubator.httpclient/jdk.incubator.http.ResponseHeaders.<init>(ResponseHeaders.java:70)
at jdk.incubator.httpclient/jdk.incubator.http.Http1Response.readHeaders(Http1Response.java:80)
at jdk.incubator.httpclient/jdk.incubator.http.Http1Exchange.getResponse(Http1Exchange.java:159)
at jdk.incubator.httpclient/jdk.incubator.http.Exchange.responseImpl0(Exchange.java:300)
at jdk.incubator.httpclient/jdk.incubator.http.Exchange.responseImpl(Exchange.java:245)
at jdk.incubator.httpclient/jdk.incubator.http.Exchange.response(Exchange.java:121)
at jdk.incubator.httpclient/jdk.incubator.http.MultiExchange.response(MultiExchange.java:154)
at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:234)
at test.SimpleHttpClientExample.main(SimpleHttpClientExample.java:15)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import jdk.incubator.http.HttpClient;
import jdk.incubator.http.HttpRequest;
import jdk.incubator.http.HttpResponse;
import java.io.IOException;
import java.net.URI;
public class SimpleHttpClientExample {
public static void main(String[] args) throws IOException, InterruptedException {
HttpClient.newHttpClient().send(HttpRequest.newBuilder(URI.create("https://www.pluralsight.com")).GET().build(),
HttpResponse.BodyHandler.asString());
}
}
---------- END SOURCE ----------
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 10.0.15063]
A DESCRIPTION OF THE PROBLEM :
When sending an HTTP request using the new HttpClient, an UnsupportedOperationException is thrown when the response headers contain double quotes.
The exception is thrown when trying to parse the following header (note the double quotes around "set-cookie"):
cache-control: max-age=0, no-cache, s-maxage=10, no-cache="set-cookie"
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Send a GET request for which the response headers will contain double quotes using the new HttpClient (for example: GET "https://www.pluralsight.com").
Please check the source code for a complete example.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The headers are parsed correctly and no exception is thrown.
ACTUAL -
java.lang.UnsupportedOperationException is thrown.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.UnsupportedOperationException
at java.base/java.util.Collections$UnmodifiableCollection.addAll(Collections.java:1066)
at jdk.incubator.httpclient/jdk.incubator.http.ResponseHeaders.lambda$parse$1(ResponseHeaders.java:162)
at java.base/java.util.HashMap.merge(HashMap.java:1301)
at jdk.incubator.httpclient/jdk.incubator.http.ResponseHeaders.parse(ResponseHeaders.java:155)
at jdk.incubator.httpclient/jdk.incubator.http.ResponseHeaders.<init>(ResponseHeaders.java:70)
at jdk.incubator.httpclient/jdk.incubator.http.Http1Response.readHeaders(Http1Response.java:80)
at jdk.incubator.httpclient/jdk.incubator.http.Http1Exchange.getResponse(Http1Exchange.java:159)
at jdk.incubator.httpclient/jdk.incubator.http.Exchange.responseImpl0(Exchange.java:300)
at jdk.incubator.httpclient/jdk.incubator.http.Exchange.responseImpl(Exchange.java:245)
at jdk.incubator.httpclient/jdk.incubator.http.Exchange.response(Exchange.java:121)
at jdk.incubator.httpclient/jdk.incubator.http.MultiExchange.response(MultiExchange.java:154)
at jdk.incubator.httpclient/jdk.incubator.http.HttpClientImpl.send(HttpClientImpl.java:234)
at test.SimpleHttpClientExample.main(SimpleHttpClientExample.java:15)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import jdk.incubator.http.HttpClient;
import jdk.incubator.http.HttpRequest;
import jdk.incubator.http.HttpResponse;
import java.io.IOException;
import java.net.URI;
public class SimpleHttpClientExample {
public static void main(String[] args) throws IOException, InterruptedException {
HttpClient.newHttpClient().send(HttpRequest.newBuilder(URI.create("https://www.pluralsight.com")).GET().build(),
HttpResponse.BodyHandler.asString());
}
}
---------- END SOURCE ----------