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

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

commit 9ee7d6afbfd0c0fe0a144a251dc7d14dfbb7a1b3
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Sep 24 21:36:19 2020 +0100

    Reduce memory footprint of closed http/2 streams
    
    This refactoring replaces closed streams with a new RecycledStream
    object and changes the mechanism used to look up known streams.
    Refactor StreamStateMachine to remove reference to Stream
---
 java/org/apache/coyote/http2/Stream.java            |  2 +-
 .../org/apache/coyote/http2/StreamStateMachine.java | 21 ++++++++++++---------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index 29cea54..2c1b714 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -97,7 +97,7 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
         this.handler = handler;
         handler.addChild(this);
         setWindowSize(handler.getRemoteSettings().getInitialWindowSize());
-        state = new StreamStateMachine(this);
+        state = new StreamStateMachine(getConnectionId(), getIdAsString());
         if (coyoteRequest == null) {
             // HTTP/2 new request
             this.coyoteRequest = new Request();
diff --git a/java/org/apache/coyote/http2/StreamStateMachine.java 
b/java/org/apache/coyote/http2/StreamStateMachine.java
index 851e1a8..72028fd 100644
--- a/java/org/apache/coyote/http2/StreamStateMachine.java
+++ b/java/org/apache/coyote/http2/StreamStateMachine.java
@@ -39,12 +39,15 @@ class StreamStateMachine {
     private static final Log log = LogFactory.getLog(StreamStateMachine.class);
     private static final StringManager sm = 
StringManager.getManager(StreamStateMachine.class);
 
-    private final Stream stream;
+    private final String connectionId;
+    private final String streamId;
+
     private State state;
 
 
-    StreamStateMachine(Stream stream) {
-        this.stream = stream;
+    StreamStateMachine(String connectionId, String streamId) {
+        this.connectionId = connectionId;
+        this.streamId = streamId;
         stateChange(null, State.IDLE);
     }
 
@@ -92,7 +95,7 @@ class StreamStateMachine {
     public synchronized void sendReset() {
         if (state == State.IDLE) {
             throw new 
IllegalStateException(sm.getString("streamStateMachine.debug.change",
-                    stream.getConnectionId(), stream.getIdAsString(), state));
+                    connectionId, streamId, state));
         }
         if (state.canReset()) {
             stateChange(state, State.CLOSED_RST_TX);
@@ -109,8 +112,8 @@ class StreamStateMachine {
         if (state == oldState) {
             state = newState;
             if (log.isDebugEnabled()) {
-                log.debug(sm.getString("streamStateMachine.debug.change", 
stream.getConnectionId(),
-                        stream.getIdAsString(), oldState, newState));
+                log.debug(sm.getString("streamStateMachine.debug.change", 
connectionId,
+                        streamId, oldState, newState));
             }
         }
     }
@@ -122,12 +125,12 @@ class StreamStateMachine {
         if (!isFrameTypePermitted(frameType)) {
             if (state.connectionErrorForInvalidFrame) {
                 throw new 
ConnectionException(sm.getString("streamStateMachine.invalidFrame",
-                        stream.getConnectionId(), stream.getIdAsString(), 
state, frameType),
+                        connectionId, streamId, state, frameType),
                         state.errorCodeForInvalidFrame);
             } else {
                 throw new 
StreamException(sm.getString("streamStateMachine.invalidFrame",
-                        stream.getConnectionId(), stream.getIdAsString(), 
state, frameType),
-                        state.errorCodeForInvalidFrame, stream.getIdAsInt());
+                        connectionId, streamId, state, frameType),
+                        state.errorCodeForInvalidFrame, 
Integer.parseInt(streamId));
             }
         }
     }


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

Reply via email to