XsdUtils.getLocalTimeString not thread safe

View: New views
3 Messages — Rating Filter:   Alert me  

XsdUtils.getLocalTimeString not thread safe

by sunh11373 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


The XsdUtils class uses a static SimpleDateFormat object to format date objects (see below). According to JDK:

>>>
Synchronization

Date formats are not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally.
<<<

We did observe strange exceptions from that class when the code runs in multi-threaded environment. This forces us to put a hard sync. on unmarshal ManagementEvent objects.

Can this be fixed quickly?

-thanks




------
public class XsdUtils
{
    //
    // Used to format dates in the XMLSchema dateTime format
    //
    private static DateFormat _FORMATTER =
        new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
   

Re: XsdUtils.getLocalTimeString not thread safe

by Chris Twiner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

If you can add issues to jira I'll try and get on them asap.

cheers,
Chris

On Mon, Jan 26, 2009 at 10:19 PM, sunh11373 <sunh11373@...> wrote:

>
>
> The XsdUtils class uses a static SimpleDateFormat object to format date
> objects (see below). According to JDK:
>
>>>>
> Synchronization
>
> Date formats are not synchronized. It is recommended to create separate
> format instances for each thread. If multiple threads access a format
> concurrently, it must be synchronized externally.
> <<<
>
> We did observe strange exceptions from that class when the code runs in
> multi-threaded environment. This forces us to put a hard sync. on unmarshal
> ManagementEvent objects.
>
> Can this be fixed quickly?
>
> -thanks
>
>
>
>
> ------
> public class XsdUtils
> {
>    //
>    // Used to format dates in the XMLSchema dateTime format
>    //
>    private static DateFormat _FORMATTER =
>        new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
>
>
> --
> View this message in context: http://www.nabble.com/XsdUtils.getLocalTimeString-not-thread-safe-tp21673971p21673971.html
> Sent from the Muse User mailing list archive at Nabble.com.
>
>

Re: XsdUtils.getLocalTimeString not thread safe

by sunh11373 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message