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

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


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 4f105d7  Make fields final after new approach to recycling
4f105d7 is described below

commit 4f105d7d4f05a34bfc9643032726b619b94bd1bd
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Mar 15 13:55:50 2021 +0000

    Make fields final after new approach to recycling
    
    The new approach to recycling replaces a Stream instance with a
    RecycledStream instance. Therefore, the fields that were made non-final
    so they could be set to null in the old approach to recycling can be
    restored to being final.
---
 java/org/apache/coyote/http2/Stream.java | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index 8f29489..788bf27 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -67,20 +67,17 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
 
     private final Http2UpgradeHandler handler;
     private final WindowAllocationManager allocationManager = new 
WindowAllocationManager(this);
+    private final Request coyoteRequest;
+    private final Response coyoteResponse = new Response();
+    private final StreamInputBuffer inputBuffer;
+    private final StreamOutputBuffer streamOutputBuffer = new 
StreamOutputBuffer();
+    private final Http2OutputBuffer http2OutputBuffer = new 
Http2OutputBuffer(coyoteResponse, streamOutputBuffer);
 
     // State machine would be too much overhead
     private int headerState = HEADER_STATE_START;
     private StreamException headerException = null;
 
-    // These will be set to null once the Stream closes to reduce the memory
-    // footprint.
-    private volatile Request coyoteRequest;
     private volatile StringBuilder cookieHeader = null;
-    private volatile Response coyoteResponse = new Response();
-    private volatile StreamInputBuffer inputBuffer;
-    private volatile StreamOutputBuffer streamOutputBuffer = new 
StreamOutputBuffer();
-    private volatile Http2OutputBuffer http2OutputBuffer =
-            new Http2OutputBuffer(coyoteResponse, streamOutputBuffer);
 
 
     Stream(Integer identifier, Http2UpgradeHandler handler) {
@@ -482,8 +479,6 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
 
 
     final ByteBuffer getInputByteBuffer() {
-        // Avoid NPE if Stream has been closed on Stream specific thread
-        StreamInputBuffer inputBuffer = this.inputBuffer;
         if (inputBuffer == null) {
             return null;
         }
@@ -515,11 +510,6 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
 
     final void receivedData(int payloadSize) throws ConnectionException {
         contentLengthReceived += payloadSize;
-        Request coyoteRequest = this.coyoteRequest;
-        // Avoid NPE if Stream has been closed on Stream specific thread
-        if (coyoteRequest == null) {
-            return;
-        }
         long contentLengthHeader = coyoteRequest.getContentLengthLong();
         if (contentLengthHeader > -1 && contentLengthReceived > 
contentLengthHeader) {
             throw new 
ConnectionException(sm.getString("stream.header.contentLength",


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

Reply via email to