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

sun.net.httpserver.LeftOverInputStream should stop attempting to drain the stream when the server is stopped

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9, 10
    • Fix Version/s: 10
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b07

      Description

      One of our internal tests is failing in timeout. The Thread Dump shows the following two threads:

      "MainThread" #12 prio=5 os_prio=64 tid=0x00000000009b0800 nid=0x20 in Object.wait() [0xffff80ff9e2fc000]
         java.lang.Thread.State: WAITING (on object monitor)
      at java.lang.Object.wait(java.base@9-ea/Native Method)
      - waiting on <0x00000000ff8f3708> (a java.lang.Thread)
      at java.lang.Thread.join(java.base@9-ea/Thread.java:1353)
      - waiting to re-lock in wait() <0x00000000ff8f3708> (a java.lang.Thread)
      at java.lang.Thread.join(java.base@9-ea/Thread.java:1427)
      at sun.net.httpserver.ServerImpl.stop(jdk.httpserver@9-ea/ServerImpl.java:211)
      at sun.net.httpserver.HttpsServerImpl.stop(jdk.httpserver@9-ea/HttpsServerImpl.java:78)
      at TestServer.stop(TestServer.java:237)

      "HTTP-Dispatcher" #39 prio=5 os_prio=64 tid=0x00000000017d8800 nid=0x3a runnable [0xffff80ff9dd7d000]
         java.lang.Thread.State: RUNNABLE
      at sun.net.httpserver.LeftOverInputStream.drain(jdk.httpserver@9-ea/LeftOverInputStream.java:119)
      at sun.net.httpserver.LeftOverInputStream.close(jdk.httpserver@9-ea/LeftOverInputStream.java:69)
      at sun.net.httpserver.ExchangeImpl.close(jdk.httpserver@9-ea/ExchangeImpl.java:146)
      at sun.net.httpserver.HttpsExchangeImpl.close(jdk.httpserver@9-ea/HttpsExchangeImpl.java:66)
      at TestServer$HttpHandler.handle(TestServer.java:574)
      at com.sun.net.httpserver.Filter$Chain.doFilter(jdk.httpserver@9-ea/Filter.java:77)
      at sun.net.httpserver.AuthFilter.doFilter(jdk.httpserver@9-ea/AuthFilter.java:82)
      at com.sun.net.httpserver.Filter$Chain.doFilter(jdk.httpserver@9-ea/Filter.java:80)
      at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(jdk.httpserver@9-ea/ServerImpl.java:685)
      at com.sun.net.httpserver.Filter$Chain.doFilter(jdk.httpserver@9-ea/Filter.java:77)
      at sun.net.httpserver.ServerImpl$Exchange.run(jdk.httpserver@9-ea/ServerImpl.java:655)
      at sun.net.httpserver.ServerImpl$DefaultExecutor.execute(jdk.httpserver@9-ea/ServerImpl.java:159)
      at sun.net.httpserver.ServerImpl$Dispatcher.handle(jdk.httpserver@9-ea/ServerImpl.java:440)
      at sun.net.httpserver.ServerImpl$Dispatcher.run(jdk.httpserver@9-ea/ServerImpl.java:405)
      at java.lang.Thread.run(java.base@9-ea/Thread.java:844)

      It appears that the MainThread is attempting to stop the server (end of the main) which causes the ServerImpl to attempt to join() the HTTP-Dispatcher thread. However, that thread appears to be spinning in LeftOverInputStream.drain().

      There is probably some subtle race condition here as the test is only failing intermittently (and infrequently).

        Attachments

          Activity

            People

            Assignee:
            dfuchs Daniel Fuchs
            Reporter:
            dfuchs Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: