Reputation: 381
I am having a concurrency issue fetching controllers from my Play Global Object.
Env:
I am sending two requests concurrently and noticed that sometimes the request ends up getting the wrong controller Example:
Request X gets Controller X
Request X gets Controller X
Request X gets Controller X
Request Y gets Controller Y //new request gets its controller
Request X gets Controller Y //new x request gets y's controller should not have happened.
Request Y gets Controller Y
Request Y gets Controller Y
Each request has a different dispatcher thread.
Here is a github app to reproduce the issue https://github.com/SaadKhawaja/play2-concurrency-test.
Please read the README file it has the steps to reproduce the issue.
Any help is appreciated.
Thanks
Upvotes: 1
Views: 196
Reputation: 12850
The problem is your action is singleton, but needs to be prototype scoped. Play injects the controller into the action for each request, so a singleton action will cause concurrency issues.
Upvotes: 2