Mark,

Is there a unit test that could be added here to test it has the intended effect?

-chris

On 1/10/25 6:19 AM, ma...@apache.org wrote:
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
      new ddf6477c1f Clear reference to stream in HPack decoder once headers 
are processed
ddf6477c1f is described below

commit ddf6477c1f0354ada82535f757f0c83c17ec25bd
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jan 10 10:54:31 2025 +0000

     Clear reference to stream in HPack decoder once headers are processed
---
  java/org/apache/coyote/http2/HpackDecoder.java | 5 +++++
  java/org/apache/coyote/http2/Http2Parser.java  | 6 ++++++
  2 files changed, 11 insertions(+)

diff --git a/java/org/apache/coyote/http2/HpackDecoder.java 
b/java/org/apache/coyote/http2/HpackDecoder.java
index 1d04406892..5257802285 100644
--- a/java/org/apache/coyote/http2/HpackDecoder.java
+++ b/java/org/apache/coyote/http2/HpackDecoder.java
@@ -405,6 +405,11 @@ public class HpackDecoder {
      }
+ void clearHeaderEmitter() {
+        headerEmitter = null;
+    }
+
+
      void setMaxHeaderCount(int maxHeaderCount) {
          this.maxHeaderCount = maxHeaderCount;
      }
diff --git a/java/org/apache/coyote/http2/Http2Parser.java 
b/java/org/apache/coyote/http2/Http2Parser.java
index ec26909761..3175637651 100644
--- a/java/org/apache/coyote/http2/Http2Parser.java
+++ b/java/org/apache/coyote/http2/Http2Parser.java
@@ -626,6 +626,12 @@ class Http2Parser {
                      Http2Error.COMPRESSION_ERROR);
          }
+ /*
+         * Clear the reference to the stream in the HPack decoder now that the 
headers have been processed so that the
+         * HPack decoder does not retain a reference to this stream. This aids 
GC.
+         */
+        hpackDecoder.clearHeaderEmitter();
+
          synchronized (output) {
              output.headersEnd(streamId, headersEndStream);

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



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

Reply via email to