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

rmaucher pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/11.0.x by this push:
     new 76dd856d46 Refactor hpackDecoder as a final field
76dd856d46 is described below

commit 76dd856d46d2d521e2f676da7305fa301329cf13
Author: remm <[email protected]>
AuthorDate: Tue May 19 21:33:26 2026 +0200

    Refactor hpackDecoder as a final field
    
    It is almost always used and it's more robust.
    BZ70050
---
 java/org/apache/coyote/http2/Http2Parser.java | 6 ++----
 webapps/docs/changelog.xml                    | 4 ++++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/coyote/http2/Http2Parser.java 
b/java/org/apache/coyote/http2/Http2Parser.java
index c75f3139e4..39d4ef310a 100644
--- a/java/org/apache/coyote/http2/Http2Parser.java
+++ b/java/org/apache/coyote/http2/Http2Parser.java
@@ -45,8 +45,8 @@ class Http2Parser {
     protected final Input input;
     private final Output output;
     private final byte[] frameHeaderBuffer = new byte[9];
+    private final HpackDecoder hpackDecoder;
 
-    private volatile HpackDecoder hpackDecoder;
     private volatile ByteBuffer headerReadBuffer = 
ByteBuffer.allocate(Constants.DEFAULT_HEADER_READ_BUFFER_SIZE);
     private volatile int headersCurrentStream = -1;
     private volatile boolean headersEndStream = false;
@@ -55,6 +55,7 @@ class Http2Parser {
         this.connectionId = connectionId;
         this.input = input;
         this.output = output;
+        this.hpackDecoder = output.getHpackDecoder();
     }
 
 
@@ -229,9 +230,6 @@ class Http2Parser {
 
         headersEndStream = Flags.isEndOfStream(flags);
 
-        if (hpackDecoder == null) {
-            hpackDecoder = output.getHpackDecoder();
-        }
         try {
             hpackDecoder.setHeaderEmitter(output.headersStart(streamId, 
headersEndStream));
         } catch (StreamException se) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index ad67ab26d0..acea8d48fa 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -156,6 +156,10 @@
       <fix>
         Improve enforcement of header trailer allow list for HTTP/2. (remm)
       </fix>
+      <fix>
+        <bug>70050</bug>: Avoid NPE when no header frame is processed in 
HTTP/2,
+        following refactor clean-up of header buffer. (remm)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Cluster">


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to