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

HttpClient PUT request fails with EOF after several successful attempts

XMLWordPrintable

      Filed to track an issue raised on net-dev:
        http://mail.openjdk.java.net/pipermail/net-dev/2018-June/011593.html

      ---
      In my random experimentation with the new HttpClient API usage, I have ended up running into an odd and hard to decipher exception when dealing with PUT requests. I am noticing that if I issue multiple PUT requests using the same HttpClient instance, the first 2 invocations succeed while the 3rd one fails with an exception[1]. Initially when I ran into this, I saw this happening depending on the size of the data being uploaded via PUT request. As soon as it hit 16385 bytes (16 KB + 1), it would end up throwing the odd exception. However, when I decided to narrow it down to a testcase, I was able to reproduce this without the size of the data playing a role. And weirdly, it now keeps failing for the third invocation.

      I have now isolated this into a jtreg testcase and created a patch against the latest upstream jdk to reproduce this issue. I've attached the patch in this mail. In the test, I create a local server and keep sending PUT requests to the server using the same instance of HttpClient. As soon as it hits the 3rd invocation, I end up seeing the exception[1].

      It's really odd, since, initially I thought it could be a size based issue, which would have been more understandable. However with the way it's failing now in this jtreg test, I am starting to wonder if I have got some basics wrong.


      [1]

      java.io.IOException: HTTP/1.1 header parser received no bytes
      at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:546)
      at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:113)
      at PUTRequestSizeTest.issuePUT(PUTRequestSizeTest.java:76)
      at PUTRequestSizeTest.main(PUTRequestSizeTest.java:61)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:115)
      at java.base/java.lang.Thread.run(Thread.java:834)
      Caused by: java.io.IOException: HTTP/1.1 header parser received no bytes
      at java.net.http/jdk.internal.net.http.common.Utils.wrapWithExtraDetail(Utils.java:293)
      at java.net.http/jdk.internal.net.http.Http1Response$HeadersReader.onReadError(Http1Response.java:646)
      at java.net.http/jdk.internal.net.http.Http1AsyncReceiver.checkForErrors(Http1AsyncReceiver.java:297)
      at java.net.http/jdk.internal.net.http.Http1AsyncReceiver.flush(Http1AsyncReceiver.java:263)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      ... 1 more
      Caused by: java.io.EOFException: EOF reached while reading
      at java.net.http/jdk.internal.net.http.Http1AsyncReceiver$Http1TubeSubscriber.onComplete(Http1AsyncReceiver.java:587)
      at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadSubscription.signalCompletion(SocketTube.java:629)
      at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.read(SocketTube.java:830)
      at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowTask.run(SocketTube.java:175)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
      at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
      at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.handleSubscribeEvent(SocketTube.java:687)
      at java.net.http/jdk.internal.net.http.AsyncTriggerEvent.handle(AsyncTriggerEvent.java:54)
      at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:796)

            dfuchs Daniel Fuchs
            chegar Chris Hegarty
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: