[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1476359 - in /subversion/trunk/subversion/bindings/javahl/src/org: apache/subversion/javahl/types/LogDate.java tigris/subversion/javahl/LogDate.java

From: Mark Phippard <markphip_at_gmail.com>
Date: Mon, 29 Apr 2013 09:40:58 -0400

On Mon, Apr 29, 2013 at 7:47 AM, Philip Martin
<philip.martin_at_wandisco.com> wrote:
> markphip_at_apache.org writes:
>
>> Author: markphip
>> Date: Fri Apr 26 19:48:34 2013
>> New Revision: 1476359
>>
>> URL: http://svn.apache.org/r1476359
>> Log:
>> 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
thread safety.

--
Thanks
Mark Phippard
http://markphip.blogspot.com/
Received on 2013-04-29 15:41:30 CEST

This is an archived mail posted to the Subversion Dev mailing list.