spring-cloud / spring-cloud/spring-cloud-gateway

No transactionId anymore in implementation classes of ErrorWebExceptionHandler

Open
#3,564 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feedback-provided
Dominant language
Java
Stars
4.9k
Forks
3.5k
Avg merge
20h 57m
Merged PRs (30d)
8

Description

Spring boot version: 3.3.2
Spring cloud dependencies version: 2023.0.3
sample issue spring cloud gateway repository: https://github.com/sigriswil/spring-gateway-sample

It contains a SpringBoot application that can be started locally. When reaching the endpoint /, it raises an exception which triggers the class GlobalErrorWebExceptionHandler which implements ErrorWebExceptionHandler.

In the main method, Hooks.enableAutomaticContextPropagation() and ContextRegistry.getInstance().registerThreadLocalAccessor(...) are called in FirstGatewayFilter.

Add the MDC's trasactionId to the FirstGatewayFilter, An exception occurs in the SecondGatewayFilterFactory.
transactionId is output from SecondGatewayFilterFactory and FirstGatewayFilter, but transactionId is not output from GlobalErrorWebExceptionHandler.

INFO 48248 --- c.e.s.FirstGatewayFilter: transactionId created. MDC: {transactionId=2e58da57-2f01-4d29-b63d-61b2e9682301}
INFO 48248 --- c.e.s.SecondGatewayFilterFactory: MDC: {transactionId=2e58da57-2f01-4d29-b63d-61b2e9682301}
ERROR 48248 --- c.e.s.GlobalErrorWebExceptionHandler: MDC: null
...
INFO 48248 --- c.e.s.FirstGatewayFilter: doFinally, MDC: {transactionId=2e58da57-2f01-4d29-b63d-61b2e9682301}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the sample application's FirstGatewayFilter, SecondGatewayFilterFactory, and GlobalErrorWebExceptionHandler, then reproduce the exception at /. Compare the MDC output before and during error handling, and verify that the transactionId remains available in GlobalErrorWebExceptionHandler.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.