Code cleanup.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2022-11-03 21:56:38 +01:00
parent b37ce63588
commit bff5b3eb8f
No known key found for this signature in database
GPG Key ID: 1677D141BCF3584D
1 changed files with 19 additions and 18 deletions

View File

@ -1501,14 +1501,15 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
/**
* <p>The HTTP/2 specification requires that stream ids are monotonically increasing,
* see https://tools.ietf.org/html/rfc7540#section-5.1.1.</p>
* see <a href="https://tools.ietf.org/html/rfc7540#section-5.1.1">RFC 7540, 5.1.1</a>.</p>
* <p>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.</p>
* <p>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.</p>
* <p>This class also coordinates the creation of streams with the close of
* the session, see https://tools.ietf.org/html/rfc7540#section-6.8.</p>
* the session, see
* <a href="https://tools.ietf.org/html/rfc7540#section-6.8">RFC 7540, 6.8</a>.</p>
*/
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<Void> shutdown()
{
CompletableFuture<Void> 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<Void> 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<Throwable> 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<Throwable> 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<HTTP2Flusher.Entry> 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(),