MathRuntimeException and MathException are both thread-hostile.
---------------------------------------------------------------
Key: MATH-253
URL: https://issues.apache.org/jira/browse/MATH-253
Project: Commons Math
Issue Type: Bug
Reporter: Sebb
Fix For: 2.0
MathRuntimeException and MathException are both thread-hostile.
They have a mutable static field cachedResources which is used in performing
translations.
If two threads use different locales - which is highly likely in the case of
non-US locales, as some methods use Locale.US - then they may get corrupt or
incorrect output.
If a cache is really desired, it could either be ThreadLocal, or volatile, but
it that case the translate method needs to fetch the value once (and update it
once if necessary).
As it stands, the method can check the resource, find it is OK, then fetch it
again to use it, by which time it might have changed. Further, one thread may
set the variable, and another thread may see a partially constructed Resources
object (it's not final).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.