-
Notifications
You must be signed in to change notification settings - Fork 25
Thread locals not set when handling exceptions in DataFetcherExceptionHandler #355
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
Comments
Which version of Boot this is? If not the latest, could you please upgrade in the first place please, there were a lot of fixes between 3.0.0 and the latest version.
Also, why do you need to register Not sure about your /cc @chemicL |
We are using springboot 3.2.4 and we are using
I tried to add Hooks.enableAutomaticContextPropagation() in @PostConstruct method of both Application.java and RequestContextWebFilter. We are not using Micrometer Tracing as we need to have some custom context for each request like requestId generated within our system. And hence we are using Slf4jThreadLocalAccessor.
This might be a big change and is not currently needed by us.
What do you mean by this ? |
Could you please only define the Boot BOM version and let it set the version numbers? Right now you are defining all version on your own, please let Spring Boot use the versions it wants to.
I was wondering if this is an issue in webflux or not. |
hi, I tried to updating to Spring Boot 3.4.4 as well. Even after the above changes it doesn't seem to work. ExceptionHandler extends DataFetcherExceptionHandler which is part of graphql-java 20.3 package. |
What do you mean by this? Looking at the |
It is also a part of reactive chains. DataFetcherExceptionHandler#handleException give DataFetcherExceptionHandlerParameters which has DataFetchingEnvironment->GraphQLContext which contains/stores the reactor context. I also tried to debug it a little the below line from the stacktrace resets the thread locals and sets it as null:
Following is the stack trace for the same:
|
hi,
We are using Hooks.enableAutomaticContextPropagation() for automatic propagation of the context and setting the MDC values in thread locals on context switch.
But unfortunately when any exception is thrown from our application code and we try to handle (prepare response + logging) these exceptions in our custom class implementing from DataFetcherExceptionHandler we find that the MDC values are not populated.
Although the reactor context is available in the DataFetcherExceptionHandler but the thread locals are not set. Could someone please help me resolve the issue. Sharing some code segments from our project:
The text was updated successfully, but these errors were encountered: