Closed jimmydivvy closed 11 years ago
This repo is no longer the official Ratpack repo, you'll probably want to visit https://github.com/tlberglund/Ratpack and submit your pull request there. Thanks!
Submitted there originally. They aren't affected by the bug, however don't consider their branch stable for real use yet.
As this branch appears to still be the basis for most of the ratpack-template projects around (And thus the version most people will currently be using), I figured it worthwhile to share the patch I've used myself to fix the issue on a project I'm working on.
Thanks, James!
The values 'params' and 'urlparams' etc from the request delegate are not thread safe. If a second request comes into a request handler while the previous one is still processing, the value of 'params' and 'urlparams' are replaced in the namespace of the original request.
My fix is to clone the request handler closure before setting the delegate, thus creating a localized namespace.
This will impart a small performance hit
To replicate the issue:
Then run
curl "http://localhost:5000/testing/ONE" & curl "http://localhost:5000/testing/TWO"
Both requests will return the same value (either ONE or TWO, depending on the order the requests execute)