line / armeria

Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
https://armeria.dev
Apache License 2.0
4.73k stars 899 forks source link

Fix to propagate `ServiceRequestContext` to `ServerErrorHandler` #5746

Closed ikhoon closed 3 weeks ago

ikhoon commented 3 weeks ago

Motivation:

An event loop of the Channel of a request is used to subscribe to a returned HttpResponse. https://github.com/line/armeria/blob/3112b50cb6d2bd0cd31bac17796c5e6a01cc347c/core/src/main/java/com/linecorp/armeria/server/HttpServerHandler.java#L453-L457 The channel event loop is not a context-aware event loop, so ServiceRequestContext is not available in the thread local. As a result, request-scoped MDC won't work.

Modifications:

Result:

ServiceRequestContext is now correctly propagated to ServerErrorHandler.

github-actions[bot] commented 3 weeks ago

๐Ÿ” Build Scanยฎ (commit: 059d61b4479d53d707f2bd5c5298c6edb7470f86)

Job name Status Build Scanยฎ
build-windows-latest-jdk-21 โœ… https://ge.armeria.dev/s/ssuqu3igg542e
build-self-hosted-unsafe-jdk-8 โœ… https://ge.armeria.dev/s/lh2kisl6iui7y
build-self-hosted-unsafe-jdk-21-snapshot-blockhound โœ… https://ge.armeria.dev/s/6g6nhmxhosflm
build-self-hosted-unsafe-jdk-17-min-java-17-coverage โœ… https://ge.armeria.dev/s/i2mcwanzofxrc
build-self-hosted-unsafe-jdk-17-min-java-11 โœ… https://ge.armeria.dev/s/4r5gecbhmrife
build-self-hosted-unsafe-jdk-17-leak โœ… https://ge.armeria.dev/s/ifkshdfq43x7c
build-self-hosted-unsafe-jdk-11 โœ… https://ge.armeria.dev/s/yepjgufka6sw4
build-macos-12-jdk-21 โœ… https://ge.armeria.dev/s/ozw3imofmdhoe
minwoox commented 3 weeks ago

@ikhoon ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘