DateFormat is not thread safe

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

DateFormat is not thread safe

Edgar Poce
Hi,

I've just downloaded the Sling code and I found that the class
org.apache.sling.obr.Repository instantiates DateFormat
implementations statically and uses them in instance methods which are
not synchronized. I'm not familiarized with the code, I'm not sure
whether the access to those methods is synchronized somewhere else,
but if they are not the the DateFormat will generate wrong string
representations of the date under heavy load.

see http://java.sun.com/j2se/1.4.2/docs/api/java/text/DateFormat.html

br,
edgar

Reply | Threaded
Open this post in threaded view
|

Re: DateFormat is not thread safe

Felix Meschberger-4
Hi Edgar,

Thanks for the hint. I just fixed it by synchronizing on the respective
DateFormat instance.

Regards
Felix

Am Freitag, den 14.09.2007, 11:15 -0300 schrieb Edgar Poce:

> Hi,
>
> I've just downloaded the Sling code and I found that the class
> org.apache.sling.obr.Repository instantiates DateFormat
> implementations statically and uses them in instance methods which are
> not synchronized. I'm not familiarized with the code, I'm not sure
> whether the access to those methods is synchronized somewhere else,
> but if they are not the the DateFormat will generate wrong string
> representations of the date under heavy load.
>
> see http://java.sun.com/j2se/1.4.2/docs/api/java/text/DateFormat.html
>
> br,
> edgar