CelestiaTheDryad opened a new pull request, #515:
URL: https://github.com/apache/httpcomponents-core/pull/515

   Using version 5.3.1
   
   We were experiencing spontaneous closures of our HTTP servers from this 
library. I traced the behavior to this stacktrace. It is caused by an exception 
occurring early in the request processing pipeline causing uninitialized state 
to be referenced.
   
   ```
   java.lang.NullPointerException: Cannot invoke 
"org.apache.hc.core5.http.nio.AsyncServerExchangeHandler.failed(java.lang.Exception)"
 because "this.exchangeHandler" is null
        at 
org.apache.hc.core5.http.impl.nio.ServerHttp1StreamHandler.failed(ServerHttp1StreamHandler.java:332)
        at 
org.apache.hc.core5.http.impl.nio.ServerHttp1StreamDuplexer.disconnected(ServerHttp1StreamDuplexer.java:225)
        at 
org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onDisconnect(AbstractHttp1StreamDuplexer.java:412)
        at 
org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.disconnected(AbstractHttp1IOEventHandler.java:95)
        at 
org.apache.hc.core5.http.impl.nio.ServerHttp1IOEventHandler.disconnected(ServerHttp1IOEventHandler.java:41)
        at 
org.apache.hc.core5.reactor.InternalDataChannel.disconnected(InternalDataChannel.java:205)
        at 
org.apache.hc.core5.reactor.SingleCoreIOReactor.processClosedSessions(SingleCoreIOReactor.java:229)
        at 
org.apache.hc.core5.reactor.SingleCoreIOReactor.doTerminate(SingleCoreIOReactor.java:104)
        at 
org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:99)
        at 
org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
        at java.base/java.lang.Thread.run(Thread.java:840)
   ```
   
   This exception is not handled in this stack, and causes the worker thread to 
exit. After all worker threads in the server exits, the server closes.
   
   An example processing error that leads to this behavior:
   ```
   org.apache.hc.core5.http.UnsupportedHttpVersionException: Unsupported 
version: HTTP/2.1
        at 
org.apache.hc.core5.http.impl.nio.ServerHttp1StreamHandler.consumeHeader(ServerHttp1StreamHandler.java:255)
        at 
org.apache.hc.core5.http.impl.nio.ServerHttp1StreamDuplexer.consumeHeader(ServerHttp1StreamDuplexer.java:372)
        at 
org.apache.hc.core5.http.impl.nio.ServerHttp1StreamDuplexer.consumeHeader(ServerHttp1StreamDuplexer.java:81)
        at 
org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onInput(AbstractHttp1StreamDuplexer.java:299)
        at 
org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.inputReady(AbstractHttp1IOEventHandler.java:64)
        at 
org.apache.hc.core5.http.impl.nio.ServerHttp1IOEventHandler.inputReady(ServerHttp1IOEventHandler.java:41)
        at 
org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:143)
        at 
org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51)
        at 
org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:176)
        at 
org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:125)
        at 
org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:92)
        at 
org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
        at java.base/java.lang.Thread.run(Thread.java:840)
   ```
   
   This PR includes the fix which I have deployed in our environment and 
appears to fix the issue in the HTTP/1 handler. We did not detect an issue in 
the HTTP/2 handler.
   
   As a separate note, I would expect the closure of the HTTP server to be 
passed to the HTTP server exception listener. As it stands there was no 
indication the server closed. It was only detected by clients reporting errors.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to