Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server-side AsyncContext initialized in lifecycle observer is lost #3111

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Nov 18, 2024

  1. Server-side AsyncContext initialized in lifecycle observer is lost

    Motivation:
    
    If users put any data into `AsyncContext` inside `HttpLifecycleObserver`
    configured via `HttpServerBuilder.lifecycleObserver(...)` it won't be
    visible for filters and service because
    `ClearAsyncContextHttpServiceFilter` is appended after
    `HttpLifecycleObserverServiceFilter` inside `applyInternalFilters`.
    
    Modifications:
    1. Move `ClearAsyncContextHttpServiceFilter` from the beginning of
    `noOffloadServiceFilters` to `applyInternalFilters`. However, this move
    discovered another bug in path that handles
    `noOffloadServiceFilters.isEmpty()` case because it never adds
    `OffloadingFilter`.
    2. Refactor `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 filters `Stream` for
    `buildService` method.
    3. Refactor `OffloadingFilter` to act as a regular filter factory
    instead of taking all further `serviceFilters` as pre-built factory.
    4. Rename `ClearAsyncContextHttpServiceFilter` singleton instance.
    5. Fix another bug when `OptionalSslNegotiator` binder takes a raw
    service instead of `filteredService` (user-defined filters were never
    applied for this path).
    6. Modify `AbstractHttpServiceAsyncContextTest` to test `AsyncContext`
    propagation from lifecycle observer and non-offloading filters.
    7. Modify `AbstractHttpServiceAsyncContextTest` to test `AsyncContext`
    initialized by early/late connection acceptor is not visible at request
    path.
    8. Add `BlockingHttpServiceAsyncContextTest` and
    `HttpServiceAsyncContextTest` to make sure `AsyncContext` propagation
    for blocking/async aggregated services is also tested.
    9. Use `ParameterizedTest` where possible.
    
    Results:
    
    1. `AsyncContext` initialized inside server's lifecycle observer is
    visible through filter chain and services.
    2. Construction of server-side filter chain is consistent and
    sequential.
    3. Filters are applied for servers with optional TLS.
    idelpivnitskiy committed Nov 18, 2024
    Configuration menu
    Copy the full SHA
    ca4f6fd View commit details
    Browse the repository at this point in the history