We are running Play 2.6 right now, and our application relies on the
Http.Context.args being a mutable Map, and the way cookies currently work, i.e.
So here are the 2 obvious problems we are facing with the 2.7 upgrade:
ThreadLocalis deprecated and
Http.Requestneeds to be passed along manually.
- The Javadoc for
Http.Context.argssimply says that you use
Http.Request.attrs()instead, but the problem is that
So here’s the current solution I came up with. I’m creating a global
public static final ThreadLocal<MyRequestContext>, and it’s initialized at the beginning of a custom
play.mvc.Filter, and then it’s automatically passed along with a custom
MyRequestContext is mutable and, in addition to storing what we used to store in
args, I’m also using it to store all the cookies I want to add/discard, and then they are processed in the end by the same
So far my solution works pretty well. What I’m asking here is whether this is considered acceptable as a long-term solution. I obviously don’t want this to stop working in the next Play update. Also, is there a more straightforward way in Play 2.7 to do mutable request scoped context? I think this is a reasonable thing to ask for since most other web frameworks, including Play 2.6, support it.