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 2022/06/28 18:42:54 UTC

[tomcat] branch 10.0.x updated: Fix potential (not observed) concurrency issues

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 577d9f0a3d Fix potential (not observed) concurrency issues
577d9f0a3d is described below

commit 577d9f0a3df177feefee68d5a774be4104f521ff
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 94cd096fb6..d01497051d 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org