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

HttpClient send throws InterruptedException when interrupted but does not cancel request

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b14
    • Verification:
      Verified

      Description

      If HttpClient is invoked with the interrupt status set, or a thread is interrupted while blocked in send, then InterruptedException will be thrown but the HTTP request continues in the background. Consider this simple example:

      Thread.currentThread().interrupt();
      HttpClient client = HttpClient.newHttpClient();
      HttpRequest request = HttpRequest.newBuilder().uri(uri)build();
      HttpResponse<String> response = client.send(request, BodyHandlers.ofString());

      InterruptedException will be thrown but if you monitor with strace or tcpdump then you'll see that the HTTP transaction continues in the background. The user of the API in the synchronous case does not have a handle to anything that can be used to cancel the operation.


        Attachments

          Issue Links

          There are no Sub-Tasks for this issue.

            Activity

              People

              Assignee:
              dfuchs Daniel Fuchs
              Reporter:
              alanb Alan Bateman
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: