bleedingwolf/Ratpack — pull request #26 by zoomzoom83 (2013-01-21 05:56:22+00:00)
Title: request delegates not thread safe

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:

get ('/testing/:value' ){

Thread.sleep(1000)

return "Value: ${urlparams.value}\n\n";

}

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)