java.net.http.HttpClient.send() and sendAsync() never complete when BodyHandler.apply() returns null

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 27
    • Affects Version/s: 19
    • Component/s: core-libs
    • None
    • master

      java.net.http.HttpClient's send() and sendAsync() methods allow for application specific java.net.http.HttpResponse$BodyHandler to be passed to those methods. If the BodyHandler implementation returns null then the internal implementation of HttpClient runs into a NullPointerException and the send() call never returns and the CompletableFuture returned by sendAsync() never completes. The NullPointerException deep within the HttpClient implementation looks like:


      Exception in thread "HttpClient-1-Worker-2" java.lang.NullPointerException: Cannot invoke "java.net.http.HttpResponse$BodySubscriber.onError(java.lang.Throwable)" because "this.userSubscriber" is null
          at java.net.http/jdk.internal.net.http.common.HttpBodySubscriberWrapper.propagateError(HttpBodySubscriberWrapper.java:171)
          at java.net.http/jdk.internal.net.http.common.HttpBodySubscriberWrapper.complete(HttpBodySubscriberWrapper.java:310)
          at java.net.http/jdk.internal.net.http.common.HttpBodySubscriberWrapper.onError(HttpBodySubscriberWrapper.java:396)
          at java.net.http/jdk.internal.net.http.Http1Response.lambda$readBody$3(Http1Response.java:402)
          at java.net.http/jdk.internal.net.http.ResponseSubscribers.lambda$getBodyAsync$0(ResponseSubscribers.java:1095)
          at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1090)
          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:614)
          at java.base/java.lang.Thread.run(Thread.java:1474)

            Assignee:
            Jaikiran Pai
            Reporter:
            Jaikiran Pai
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: