Server-side AsyncContext
initialized in lifecycle observer is lost
#3111
+574
−208
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation:
If users put any data into
AsyncContext
insideHttpLifecycleObserver
configured viaHttpServerBuilder.lifecycleObserver(...)
it won't be visible for filters and service becauseClearAsyncContextHttpServiceFilter
is appended afterHttpLifecycleObserverServiceFilter
insideapplyInternalFilters
.Modifications:
ClearAsyncContextHttpServiceFilter
from the beginning ofnoOffloadServiceFilters
toapplyInternalFilters
. However, this move discovered another bug in path that handlesnoOffloadServiceFilters.isEmpty()
case because it never addsOffloadingFilter
.listenForService
method to always make a copy of filters lists, then prepend/append internal filters to those copies in easy to read/understand way, and construct a single filtersStream
forbuildService
method.OffloadingFilter
to act as a regular filter factory instead of taking all furtherserviceFilters
as pre-built factory.ClearAsyncContextHttpServiceFilter
singleton instance.OptionalSslNegotiator
binder takes a raw service instead offilteredService
(user-defined filters were never applied for this path).AbstractHttpServiceAsyncContextTest
to testAsyncContext
propagation from lifecycle observer and non-offloading filters.AbstractHttpServiceAsyncContextTest
to testAsyncContext
initialized by early/late connection acceptor is not visible at request path.BlockingHttpServiceAsyncContextTest
andHttpServiceAsyncContextTest
to make sureAsyncContext
propagation for blocking/async aggregated services is also tested.ParameterizedTest
where possible.Results:
AsyncContext
initialized inside server's lifecycle observer is visible through filter chain and services.