com.sun.net.httpserver.HttpServer: Sending the response headers before draining the request body can cause AssertionError

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P4
    • tbd
    • Affects Version/s: None
    • Component/s: core-libs
    • None

      If a custom HttpHandler calls HttpExchange.sendResponseHeaders() followed by HttpExchange.close() without first calling HttpExchange.getRequestBody().readAllBytes(), an assertion error may occur:

      java.lang.AssertionError
      at jdk.httpserver/sun.net.httpserver.ServerImpl.responseCompleted(ServerImpl.java:805)
      at jdk.httpserver/sun.net.httpserver.ServerImpl$Dispatcher.handleEvent(ServerImpl.java:293)
      at jdk.httpserver/sun.net.httpserver.ServerImpl$Dispatcher.run(ServerImpl.java:352)
      at java.base/java.lang.Thread.run(Thread.java:844)

      If assertions are not enabled, the server may close the channel even though keep-alive was requested, which may cause performance drops (or authentication failures for authentication scheme like NTLM/Negotiate where the server needs two trips authentication and expects the second message to come from the same channel).

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

              Created:
              Updated:
              Resolved: