NumberConverter not threadsafe


Jeff Caswell's patch applied:

We have been having a number of issues with story parameter conversion and number format errors in a multithreaded environment.

This was tracked back to the java.text.NumberFormat instance held by the ParameterConverters NumberConverter inner class.

The constructor is only run once when a number of stories are launched and the instance is used by all the stories in the run.

I suspect there may be other issues affecting this, however by converting the NumberFormat to ThreadLocal storage has solved the problem here.

The patch is pretty much self explanitory, the only aspect that may not immediately seem obvious is that the NumberFormat passed in on the constructor was itself constructed with the users preferred Locale. It is for this reason that I have treated it as the 'preferred format' and cloned it for the thread local copy. Also I did not issue an explicit remove since tests are run as a relatively short lived batch job and I did not feel that there was any reason to worry about an associated memory leak.


Paul Hammant


Paul Hammant




Fix versions

Affects versions