diff --git a/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2ClientSession.java b/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2ClientSession.java index 794531ff517..7fb8c49e183 100644 --- a/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2ClientSession.java +++ b/jetty-http2/http2-client/src/main/java/org/eclipse/jetty/http2/client/HTTP2ClientSession.java @@ -63,10 +63,9 @@ public class HTTP2ClientSession extends HTTP2Session else { stream.process(frame, Callback.NOOP); - boolean closed = stream.updateClose(frame.isEndStream(), CloseState.Event.RECEIVED); - notifyHeaders(stream, frame); - if (closed) + if (stream.updateClose(frame.isEndStream(), CloseState.Event.RECEIVED)) removeStream(stream); + notifyHeaders(stream, frame); } } else diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Stream.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Stream.java index 6531d05afea..0b38ccf1782 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Stream.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Stream.java @@ -357,10 +357,10 @@ public class HTTP2Stream extends IdleTimeout implements IStream, Callback, Dumpa } } - boolean closed = updateClose(frame.isEndStream(), CloseState.Event.RECEIVED); - notifyData(this, frame, callback); - if (closed) + if (updateClose(frame.isEndStream(), CloseState.Event.RECEIVED)) session.removeStream(this); + + notifyData(this, frame, callback); } private void onReset(ResetFrame frame, Callback callback) diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerSession.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerSession.java index 26808f8fd6d..f5c28083be3 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerSession.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerSession.java @@ -104,11 +104,10 @@ public class HTTP2ServerSession extends HTTP2Session implements ServerParser.Lis { onStreamOpened(stream); stream.process(frame, Callback.NOOP); - boolean closed = stream.updateClose(frame.isEndStream(), CloseState.Event.RECEIVED); + if (stream.updateClose(frame.isEndStream(), CloseState.Event.RECEIVED)) + removeStream(stream); Stream.Listener listener = notifyNewStream(stream, frame); stream.setListener(listener); - if (closed) - removeStream(stream); } } } @@ -127,10 +126,9 @@ public class HTTP2ServerSession extends HTTP2Session implements ServerParser.Lis if (stream != null) { stream.process(frame, Callback.NOOP); - boolean closed = stream.updateClose(frame.isEndStream(), CloseState.Event.RECEIVED); - notifyHeaders(stream, frame); - if (closed) + if (stream.updateClose(frame.isEndStream(), CloseState.Event.RECEIVED)) removeStream(stream); + notifyHeaders(stream, frame); } else {