Example URI string parsed by new URI(string) that contains an encoded reserved character "#" (%23) in the query string:
http://localhost:34455/ldp-test-43272e5c-1e3f-4bb8-8541-fa5ea6d6567a?predicate=http%3A%2F%2Fwww.w3.org%2Fns%2Foa%23hasBody
The URI object is then simply passed to HttpRequest.newBuilder(uri)
Here is the log, the first entry shows that the server processed request string is truncated, yet the response and request URIs show the complete string:
127.0.0.1 - - [22/Feb/2018:10:30:51 +0000] "GET /ldp-test-43272e5c-
1e3f-4bb8-8541-fa5ea6d6567a?predicate=http://www.w3.org/ns/oa
HTTP/1.1" 200 3 "-" "-" 64
INFO [2018-02-22 10:30:51,137] cool.pandora.ldpclient.LdpClientImpl:
request URI is http://localhost:34455/ldp-test-43272e5c-1e3f-4bb8-
8541-fa5ea6d6567a?
predicate=http%3A%2F%2Fwww.w3.org%2Fns%2Foa%23hasBody
INFO [2018-02-22 10:30:51,141] cool.pandora.ldpclient.LdpClientImpl:
response URI is http://localhost:34455/ldp-test-43272e5c-1e3f-4bb8-
8541-fa5ea6d6567a?
predicate=http%3A%2F%2Fwww.w3.org%2Fns%2Foa%23hasBody
INFO [2018-02-22 10:30:51,141] cool.pandora.ldpclient.LdpClientImpl:
http version is HTTP_1_1
INFO [2018-02-22 10:30:51,141] cool.pandora.ldpclient.LdpClientImpl:
status code is 200
INFO [2018-02-22 10:30:51,141] cool.pandora.ldpclient.LdpClientImpl:
final request URI is http://localhost:34455/ldp-test-43272e5c-1e3f-
4bb8-8541-fa5ea6d6567a?
predicate=http%3A%2F%2Fwww.w3.org%2Fns%2Foa%23hasBody
INFO [2018-02-22 10:30:51,141] cool.pandora.ldpclient.LdpClientImpl:
Content Length is[3]
this seems to be a bug in the jdk.incubator.http and not in URI.
It is not clear to me in the Exchange if additional URI string building or construction occurs, but if the query string is decoded somewhere without reencoding it would be my first guess as the suspect.
Perhaps someone can independently verify this?
Also, I believe that it is not the server implementation because the same request URI (on a non-test instance) with curl works.
172.18.0.1 - - [22/Feb/2018:09:22:31 +0000] "GET /test10?
predicate=http%3A%2F%2Fwww.w3.org%2Fns%2Foa%23hasBody HTTP/1.1" 200
795 "-" "curl/7.55.1" 35