Java 9 HttpClient hangs

Viewed 1258

I'm experimenting with HTTP/2 client from jdk 9-ea+171. The code is taken from this example:

HttpClient client = HttpClient.newHttpClient();

HttpRequest request = HttpRequest.newBuilder()
    .uri(new URI("https://www.google.com/"))
    .build();

HttpResponse<String> response
        = client.send(request, HttpResponse.BodyHandler.asString());

But the client hangs on the last line forever. Please advice how to fix it?

Debugging shows it infinitely waits in method waitUntilPrefaceSent().

1 Answers
Related