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 5782322  Fix (hopefully) intermittently failing test
5782322 is described below

commit 5782322afd31adf98b72288f99965c6811dcdcdd
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Nov 29 17:09:45 2021 +0000

    Fix (hopefully) intermittently failing test
---
 java/org/apache/coyote/http2/Stream.java | 10 ++++++++--
 webapps/docs/changelog.xml               |  6 ++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index 5ad9396..e3d6fa8 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -660,8 +660,14 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
                     log.debug(sm.getString("stream.reset.send", 
getConnectionId(), getIdAsString(),
                             se.getError()));
                 }
-                state.sendReset();
-                handler.sendStreamReset(se);
+                // Sync ensures that if the call to sendReset() triggers resets
+                // in other threads, that the RST frame associated with this
+                // thread is sent before the RST frames associated with those
+                // threads.
+                synchronized (state) {
+                    state.sendReset();
+                    handler.sendStreamReset(se);
+                }
                 cancelAllocationRequests();
                 if (inputBuffer != null) {
                     inputBuffer.swallowUnread();
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index d30b852..edeef04 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -170,6 +170,11 @@
         <bug>65677</bug>: Improve exception handling for errors during HTTP/1.1
         reads with NIO2. (markt)
       </fix>
+      <fix>
+        When an error occurs that triggers a stream reset, ensure that the 
first
+        <code>RST</code> frame sent to the client is the one associated with 
the
+        error that triggered the reset. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="WebSocket">
@@ -1205,3 +1210,4 @@
 </section>
 </body>
 </document>
+

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

Reply via email to