Uploaded image for project: 'HttpComponents HttpCore'
  1. HttpComponents HttpCore
  2. HTTPCORE-228

NullPointerException in AsyncNHttpServiceHandler on empty entity-enclosing request

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.1
    • 4.1-beta2
    • HttpCore NIO
    • None

    Description

      When a client sends an entity-enclosing request, but does not include an entity, an IOReactorException is thrown which in turns terminates the server. The cause appears to be a missing null-check around line 317 in the following code:

      313 ConsumingNHttpEntity consumingEntity = connState.getConsumingEntity();
      314
      315 try {
      316
      317 consumingEntity.consumeContent(decoder, conn);
      318 if (decoder.isCompleted())

      { 319 conn.suspendInput(); 320 processRequest(conn, request); 321 }

      The issue can be reproduced using the following:

      [sam@dev3 ~]$ curl -v -d "" https://proj.acmecorp.com/

      • About to connect() to proj.acmecorp.com port 443
      • Trying 192.168.254.22... connected
      • Connected to proj.acmecorp.com (192.168.254.22) port 443
      • SSL certificate verify ok.
        > POST / HTTP/1.1
        > User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
        > Host: proj.acmecorp.com
        > Accept: /
        > Content-Length: 0
        > Content-Type: application/x-www-form-urlencoded
        >
        (No response is ever received)

      Complete stacktrace:

      INFO com.acmecorp.proj.http.HttpSSLServer: Connection open: [proj.acmecorp.com/192.168.254.22:47992]
      ERROR com.acmecorp.proj.http.HttpSSLServer: I/O error
      org.apache.http.nio.reactor.IOReactorException: I/O dispatch worker terminated abnormally
      at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:326)
      at com.acmecorp.proj.http.HttpSSLServer$1.run(HttpSSLServer.java:162)
      Caused by: java.lang.NullPointerException
      at org.apache.http.nio.protocol.AsyncNHttpServiceHandler.inputReady(AsyncNHttpServiceHandler.java:317)
      at org.apache.http.impl.nio.DefaultNHttpServerConnection.consumeInput(DefaultNHttpServerConnection.java:179)
      at org.apache.http.impl.nio.SSLServerIOEventDispatch.inputReady(SSLServerIOEventDispatch.java:225)
      at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:153)
      at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:314)
      at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:294)
      at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:256)
      at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:96)
      at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:556)
      at java.lang.Thread.run(Thread.java:619)
      INFO com.acmecorp.proj.http.HttpSSLServer: Shutdown HTTP server

      Attachments

        Activity

          People

            Unassigned Unassigned
            samcrawford Sam Crawford
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: