Skip to content

Commit

Permalink
Clear reference to stream in HPack decoder once headers are processed
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Jan 10, 2025
1 parent b89bfaf commit cbdf826
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions java/org/apache/coyote/http2/HpackDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ void setHeaderEmitter(HeaderEmitter headerEmitter) {
}


void clearHeaderEmitter() {
headerEmitter = null;
}


void setMaxHeaderCount(int maxHeaderCount) {
this.maxHeaderCount = maxHeaderCount;
}
Expand Down
6 changes: 6 additions & 0 deletions java/org/apache/coyote/http2/Http2Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,12 @@ protected void onHeadersComplete(int streamId) throws Http2Exception {
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);

Expand Down

0 comments on commit cbdf826

Please sign in to comment.