Package org.mockserver.netty
Class InFlightRequest
java.lang.Object
org.mockserver.netty.InFlightRequest
Per-request in-flight token used by the WS7.2 graceful-shutdown connection drain.
A token is created and LifeCycle.requestProcessingStarted() is incremented exactly once
when a data-plane HTTP request begins processing in HttpRequestHandler.channelRead0(io.netty.channel.ChannelHandlerContext, org.mockserver.model.HttpRequest). The
matching LifeCycle.requestProcessingComplete() decrement is driven by complete(),
which is invoked from whichever of these fires first:
- the response funnel —
NettyResponseWriter.sendResponse(...), through which every data-plane response flows (normal, streaming, chunked, forward/proxy, error/exception, breakpoint-modified); or - the channel
closeFuturesafety net — covers requests that never produce a response (connection drop or pipeline-killing exception mid-processing).
An AtomicBoolean guard guarantees the decrement fires exactly once regardless
of how many of those hooks fire, so the in-flight counter can never leak (which would make
stop() always wait the full drain timeout) nor be decremented twice.
- Author:
- jamesdbloom
-
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete()Decrement the in-flight counter, but only the first time this is called for this token.static InFlightRequestIncrement the in-flight counter and return a token whosecomplete()will decrement it exactly once.
-
Method Details
-
started
Increment the in-flight counter and return a token whosecomplete()will decrement it exactly once. Returnsnullwhen noLifeCycleis available (so callers can no-op safely). -
complete
public void complete()Decrement the in-flight counter, but only the first time this is called for this token. Safe to call from any thread and from multiple completion hooks.
-