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

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


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 9fe8413b4c Fix potential (not observed) concurrency issues
9fe8413b4c is described below

commit 9fe8413b4cb1b27535708b0360709f7146ff1254
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Jun 28 19:42:31 2022 +0100

    Fix potential (not observed) concurrency issues
    
    I have been investigating some HTTP/2 test failures and noticed that
    these fields could be accessed by multiple threads. Make the fields
    volatile to ensure that the changes made by the previous thread are
    visible to the current thread.
---
 java/org/apache/coyote/http2/Http2AsyncParser.java | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/java/org/apache/coyote/http2/Http2AsyncParser.java 
b/java/org/apache/coyote/http2/Http2AsyncParser.java
index 89cdc8268e..4e76b12c0c 100644
--- a/java/org/apache/coyote/http2/Http2AsyncParser.java
+++ b/java/org/apache/coyote/http2/Http2AsyncParser.java
@@ -59,12 +59,12 @@ class Http2AsyncParser extends Http2Parser {
 
     private class PrefaceCompletionHandler extends FrameCompletionHandler {
 
-        private boolean prefaceValidated = false;
-
         private final WebConnection webConnection;
         private final Stream stream;
         private final byte[] prefaceData;
 
+        private volatile boolean prefaceValidated = false;
+
         private PrefaceCompletionHandler(WebConnection webConnection, Stream 
stream, byte[] prefaceData, ByteBuffer... buffers) {
             super(FrameType.SETTINGS, buffers);
             this.webConnection = webConnection;
@@ -166,15 +166,15 @@ class Http2AsyncParser extends Http2Parser {
         private final FrameType expected;
         protected final ByteBuffer[] buffers;
 
-        private boolean parsedFrameHeader = false;
-        private boolean validated = false;
-        private CompletionState state = null;
-        protected int payloadSize;
-        protected int frameTypeId;
-        protected FrameType frameType;
-        protected int flags;
-        protected int streamId;
-        protected boolean streamException = false;
+        private volatile boolean parsedFrameHeader = false;
+        private volatile boolean validated = false;
+        private volatile CompletionState state = null;
+        protected volatile int payloadSize;
+        protected volatile int frameTypeId;
+        protected volatile FrameType frameType;
+        protected volatile int flags;
+        protected volatile int streamId;
+        protected volatile boolean streamException = false;
 
         private FrameCompletionHandler(FrameType expected, ByteBuffer... 
buffers) {
             this.expected = expected;


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

Reply via email to