Spring gRPC Contexts don't work as expected

Hey! I'm using Spring Boot gRPC and encountered the problem that my set context (which I prepare in a @ServerInterceptor) is not used in exceptions at @GrpcAdvice ExceptionHandler. It handles Context.current() generation 5, while I intercept all incoming calls with a context of generation 6, in which I have prepared the user's metadata. The service methods also work with Context.current() with generation 6 and have access to the prepared metadata, but the exception handler does not. How can I tell my ExceptionHandler to use the latest context generation (which should be 6 and not 5)? Thanks in advance!
3 Replies
JavaBot
JavaBot5mo ago
This post has been reserved for your question.
Hey @Jonas! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Jonas
JonasOP5mo ago
Well, as mentioned in the original post message, I'm just using Context.current() in the same way as in the service methods, but in the exception handler, it just refers to an older context version. I'm pretty sure that it's caused by a wrong order, that the exceptionAdvice gets called before the interceptor so the exceptionAdvice got no chance to get the new version.
JavaBot
JavaBot5mo ago
Post Closed
This post has been closed by <@421671659146313729>.

Did you find this page helpful?