From eb00ac2ddeb0b11e84c76fc3573fe2bd5dadc077 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 1 Dec 2020 12:55:23 +0100 Subject: [PATCH] Restored first-close-and-remove-then-notify ordering that was changed with the changes for #5310. This is important in tests that check that streams have been removed from sessions after counting down a latch in the notification. Signed-off-by: Simone Bordet --- .../eclipse/jetty/http2/client/HTTP2ClientSession.java | 5 ++--- .../main/java/org/eclipse/jetty/http2/HTTP2Stream.java | 6 +++--- .../eclipse/jetty/http2/server/HTTP2ServerSession.java | 10 ++++------ 3 files changed, 9 insertions(+), 12 deletions(-) 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 {