Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8164526

If response has no body, HTTP_2 client would raise java.io.IOException: Queue closed

XMLWordPrintable

      public class SimpleConnectTest {

          public static void main(String[] args) throws Exception {
              String url = "..."; // This access won't return body
              HttpClient client = HttpClient.create().version(Version.HTTP_2).build();
              HttpRequest request = client.request(new URI(url)).GET();
              HttpResponse<String> response = request.response(HttpResponse.BodyHandler.asString());
              System.out.println(response.statusCode());
              System.out.println(response.body());
          }
      }

      Exception in thread "main" java.io.IOException: Queue closed
              at java.net.http.Queue.take(java.httpclient@9-internal/Queue.java:113)
              at java.net.http.Stream.lambda$receiveData$1(java.httpclient@9-internal/Stream.java:187)
              at java.net.http.Stream.executeInline(java.httpclient@9-internal/Stream.java:164)
              at java.net.http.Stream.receiveData(java.httpclient@9-internal/Stream.java:182)
              at java.net.http.Stream.readBodyAsync(java.httpclient@9-internal/Stream.java:142)
              at java.net.http.Stream.readBody(java.httpclient@9-internal/Stream.java:155)
              at java.net.http.Exchange.readBody(java.httpclient@9-internal/Exchange.java:131)
              at java.net.http.MultiExchange.response(java.httpclient@9-internal/MultiExchange.java:121)
              at java.net.http.HttpRequestImpl.response(java.httpclient@9-internal/HttpRequestImpl.java:251)
              at SimpleConnectTest.main(SimpleConnectTest.java:13)

            chegar Chris Hegarty
            jjiang John Jiang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: