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

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


The following commit(s) were added to refs/heads/10.0.x by this push:
     new 547724770d Additional fix for BZ 65118 - NPE on HTTP/2 prune
547724770d is described below

commit 547724770d523b92c5ddb73dd15d6141d09b7812
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri May 27 11:26:33 2022 +0100

    Additional fix for BZ 65118 - NPE on HTTP/2 prune
    
    Expand priorityTree sync to include looking up the streams to be
    reprioritised.
---
 .../org/apache/coyote/http2/Http2UpgradeHandler.java | 20 ++++++++++++--------
 webapps/docs/changelog.xml                           |  5 +++++
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java 
b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index 03dc48c667..8b7ec85cc5 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -1654,15 +1654,19 @@ class Http2UpgradeHandler extends AbstractStream 
implements InternalHttpUpgradeH
 
         increaseOverheadCount(FrameType.PRIORITY);
 
-        AbstractNonZeroStream abstractNonZeroStream = 
getAbstractNonZeroStream(streamId);
-        if (abstractNonZeroStream == null) {
-            abstractNonZeroStream = createRemoteStream(streamId);
-        }
-        AbstractStream parentStream = getAbstractNonZeroStream(parentStreamId);
-        if (parentStream == null) {
-            parentStream = this;
-        }
         synchronized (priorityTreeLock) {
+            // Need to look up stream and parent stream inside the lock else it
+            // is possible for a stream to be recycled before it is
+            // reprioritised. This can result in incorrect references to the
+            // non-recycled stream being retained after reprioritisation.
+            AbstractNonZeroStream abstractNonZeroStream = 
getAbstractNonZeroStream(streamId);
+            if (abstractNonZeroStream == null) {
+                abstractNonZeroStream = createRemoteStream(streamId);
+            }
+            AbstractStream parentStream = 
getAbstractNonZeroStream(parentStreamId);
+            if (parentStream == null) {
+                parentStream = this;
+            }
             abstractNonZeroStream.rePrioritise(parentStream, exclusive, 
weight);
         }
     }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 30fcd1749c..dbe1f74c87 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -133,6 +133,11 @@
   </subsection>
   <subsection name="Coyote">
     <changelog>
+      <fix>
+        Additional fix for <bug>65118</bug>. Fix a potential
+        <code>NullPointerException</code> when pruning closed HTTP/2 streams
+        from the connection. (markt)
+      </fix>
       <fix>
         <bug>66076</bug>: When using TLS with non-blocking writes and the NIO
         connector, ensure that flushing the buffers attempts to empty all of 
the


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

Reply via email to