On Mon, Apr 29, 2013 at 7:47 AM, Philip Martin
> markphip_at_apache.org writes:
>> Author: markphip
>> Date: Fri Apr 26 19:48:34 2013
>> New Revision: 1476359
>> URL: http://svn.apache.org/r1476359
>> JavaHL: fix a thread safety bug that has been observed in Subclipse.
>> The Java SimpleDateFormat class is not thread safe. Solved by
>> synchronizing the use of the object. Also audited all of our usage of
>> this class and only this one usage has an issue. There are alternate
>> implementations we could use, but we would have to copy in the class
>> to our package. I chose to take the simple approach.
> Would it be possible to switch to a non-static DateFormat instead?
This would essentially require creating a new object each time the
method is needed and that would be a lot. My understanding is that
using synchronize is cheaper in this case.
The more complicated, but possibly better, solution would be to either
introduce the class I mentioned as an InnerClass to LogDate so that we
could use it, or perhaps even just recreate some of the logic it uses
with ThreadLocal to manage it all internally within this class.
Again, since we only have one place in our code that needs this we do
not really require a full-blown replacement for SimpleDateFormat.
I opted for the smaller code change by using synchronized to insure
Received on 2013-04-29 15:41:30 CEST