From bff5b3eb8f5547afd8883029555dd46d06ed7a77 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 3 Nov 2022 21:56:38 +0100 Subject: [PATCH] Code cleanup. Signed-off-by: Simone Bordet --- .../org/eclipse/jetty/http2/HTTP2Session.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java index b2da4a0f9ef..f4b0b78cf10 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java @@ -1501,14 +1501,15 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio /** *

The HTTP/2 specification requires that stream ids are monotonically increasing, - * see https://tools.ietf.org/html/rfc7540#section-5.1.1.

+ * see RFC 7540, 5.1.1.

*

This implementation uses a queue to atomically reserve a stream id and claim * a slot in the queue; the slot is then assigned the entries to write.

*

Concurrent threads push slots in the queue but only one thread flushes * the slots, up to the slot that has a non-null entries to write, therefore * guaranteeing that frames are sent strictly in their stream id order.

*

This class also coordinates the creation of streams with the close of - * the session, see https://tools.ietf.org/html/rfc7540#section-6.8.

+ * the session, see + * RFC 7540, 6.8.

*/ private class StreamsState { @@ -1527,7 +1528,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio private CloseState getCloseState() { - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { return closed; } @@ -1536,7 +1537,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio private CompletableFuture shutdown() { CompletableFuture future; - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { if (shutdownCallback != null) return shutdownCallback; @@ -1550,7 +1551,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio { boolean sendGoAway = false; boolean tryRunZeroStreamsAction = false; - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { switch (closed) { @@ -1661,7 +1662,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio LOG.debug("Halting ({}) for {}", reason, HTTP2Session.this); GoAwayFrame goAwayFrame = null; GoAwayFrame goAwayFrameEvent; - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { switch (closed) { @@ -1696,7 +1697,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio { boolean failStreams = false; boolean tryRunZeroStreamsAction = false; - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { switch (closed) { @@ -1806,7 +1807,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio String reason = "input_shutdown"; Throwable cause = null; boolean failStreams = false; - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { switch (closed) { @@ -1866,7 +1867,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio boolean sendGoAway = false; GoAwayFrame goAwayFrame = null; Throwable cause = null; - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { switch (closed) { @@ -1933,7 +1934,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio { GoAwayFrame goAwayFrame; Throwable cause; - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { switch (closed) { @@ -1970,7 +1971,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio private void onWriteFailure(Throwable x) { String reason = "write_failure"; - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { switch (closed) { @@ -2028,7 +2029,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio // but only one moves to CLOSED and runs the action. Runnable action = null; CompletableFuture future; - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { long count = streamCount.get(); if (count > 0) @@ -2133,7 +2134,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio private Stream newUpgradeStream(HeadersFrame frame, Stream.Listener listener, Consumer failFn) { int streamId; - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { streamId = localStreamIds.getAndAdd(2); HTTP2Session.this.onStreamCreated(streamId); @@ -2153,7 +2154,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio private boolean newRemoteStream(int streamId) { - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { switch (closed) { @@ -2237,7 +2238,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio private int reserveSlot(Slot slot, int streamId, Consumer fail) { Throwable failure = null; - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { if (closed == CloseState.NOT_CLOSED) { @@ -2263,7 +2264,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio private void freeSlot(Slot slot, int streamId) { - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { slots.remove(slot); } @@ -2292,7 +2293,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio while (true) { List entries; - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { if (flushing == null) flushing = thread; @@ -2320,7 +2321,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio @Override public String toString() { - try (AutoLock l = lock.lock()) + try (AutoLock ignored = lock.lock()) { return String.format("state=[streams=%d,%s,goAwayRecv=%s,goAwaySent=%s,failure=%s]", streamCount.get(),