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
commit d6ddfaa1b3729feb78afd9093eaff4a3d2a2b859 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 78a288c..260ce54 100644 --- a/java/org/apache/coyote/http2/Stream.java +++ b/java/org/apache/coyote/http2/Stream.java @@ -94,7 +94,7 @@ public 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 66aee45..fdc06a4 100644 --- a/java/org/apache/coyote/http2/StreamStateMachine.java +++ b/java/org/apache/coyote/http2/StreamStateMachine.java @@ -39,12 +39,15 @@ public 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; - public StreamStateMachine(Stream stream) { - this.stream = stream; + public StreamStateMachine(String connectionId, String streamId) { + this.connectionId = connectionId; + this.streamId = streamId; stateChange(null, State.IDLE); } @@ -97,7 +100,7 @@ public 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); @@ -114,8 +117,8 @@ public 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)); } } } @@ -127,12 +130,12 @@ public 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