You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2025/02/12 10:55:35 UTC

(httpcomponents-core) branch 5.3.x updated: Bug fix: ServerHttp1StreamHandler causes an NPE when attempting to handle a corrupt / invalid incoming request message head

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch 5.3.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git


The following commit(s) were added to refs/heads/5.3.x by this push:
     new 04f2cdd39 Bug fix: ServerHttp1StreamHandler causes an NPE when attempting to handle a corrupt / invalid incoming request message head
04f2cdd39 is described below

commit 04f2cdd3906f3639da2a8fcecec622f9644383f0
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Wed Feb 12 11:52:01 2025 +0100

    Bug fix: ServerHttp1StreamHandler causes an NPE when attempting to handle a corrupt / invalid incoming request message head
---
 .../org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java
index f5409404d..74cee8698 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java
@@ -331,7 +331,7 @@ void dataEnd(final List<? extends Header> trailers) throws HttpException, IOExce
     }
 
     void failed(final Exception cause) {
-        if (!done.get()) {
+        if (!done.get() && exchangeHandler != null) {
             exchangeHandler.failed(cause);
         }
     }
@@ -341,7 +341,9 @@ public void releaseResources() {
         if (done.compareAndSet(false, true)) {
             requestState = MessageState.COMPLETE;
             responseState = MessageState.COMPLETE;
-            exchangeHandler.releaseResources();
+            if (exchangeHandler != null) {
+                exchangeHandler.releaseResources();
+            }
         }
     }