commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] Created: (MATH-253) MathRuntimeException and MathException are both thread-hostile.
Date Sat, 04 Apr 2009 21:23:12 GMT
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.


Mime
View raw message