-
Notifications
You must be signed in to change notification settings - Fork 43
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
getOrElseUpdate and http context #130
Comments
Hi, I am sorry, I am not much familiar with Java API, I use only Scala version. Could you give me more details about the context and how it is stored? Some link would be great to know what I am looking for. Thanks |
The context is stored on the thread local. When you do something like:
Play offers you a class called In scala you don't have these problems, but if you are doing a java version you still need to be aware of this topic. In the class |
Not all async APIs take Executor from the caller, so we can't expect them to do any context propagation for you. Since you are using the Java API, the proper way to propagate context is to use the async versions of the CompletionStage API and pass in the injected HttpExecutionContext. Using your example: |
if the |
It doesn't matter whether the first stage has the context or not. |
and what happens if I need the context inside of the callable in the |
In that case, you capture the context beforehand.
|
ok... I have the following method: |
Yes.
|
Thanks! |
You are welcome. |
@tzimisce012 Thanks for the very nice and detailed explanation of the context, I understand it. @johnsiu Thank you very much for your great work and the proposed workaround. I'll look at this issue and see what the Play does inside its default implementation and consider reopening this issue. I believe that missing the context inside the |
Great. I also believe that the workaround is good but It would be cool if we can fix this topic from the implementation of RedisCache :) |
Released |
I am having the following issue. When I use this java method I am loosing the http context.
Reporting a bug?
CompletionStage
with the http.contextThe text was updated successfully, but these errors were encountered: