You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/03/12 12:12:10 UTC
[tomcat] 01/02: Avoid multiple attempts to recycle an HTTP/2 stream
triggering an NPE
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit d5c773bed0793b872ac21e675cf5777538acf1cd
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Mar 12 12:10:58 2021 +0000
Avoid multiple attempts to recycle an HTTP/2 stream triggering an NPE
---
java/org/apache/coyote/http2/Http2UpgradeHandler.java | 10 ++++++++--
webapps/docs/changelog.xml | 5 +++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index eaf7e88..bf48daf 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -1762,8 +1762,14 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
void replaceStream(AbstractNonZeroStream original, AbstractNonZeroStream replacement) {
synchronized (priorityTreeLock) {
- streams.replace(original.getIdentifier(), replacement);
- original.replaceStream(replacement);
+ AbstractNonZeroStream current = streams.get(original.getIdentifier());
+ // Might already have been recycled or removed from the priority
+ // tree entirely. Only replace it if the full stream is still in the
+ // priority tree.
+ if (current instanceof Stream) {
+ streams.put(original.getIdentifier(), replacement);
+ original.replaceStream(replacement);
+ }
}
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 556b213..e31899e 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -110,6 +110,11 @@
Improve consistency of OpenSSL error stack handling in the TLS engine,
and log all errors found as debug. (remm)
</fix>
+ <fix>
+ Ensure that HTTP/2 streams are only recycled once as multiple attempts
+ to recycle an HTTP/2 stream may result in
+ <code>NullPointerException</code>s. (markt)
+ </fix>
</changelog>
</subsection>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org