You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-user@ws.apache.org by sunh11373 <su...@yahoo.com> on 2009/01/26 22:19:00 UTC

XsdUtils.getLocalTimeString not thread safe


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

Posted by sunh11373 <su...@yahoo.com>.
Created the bug https://issues.apache.org/jira/browse/MUSE-297
-- 
View this message in context: http://www.nabble.com/XsdUtils.getLocalTimeString-not-thread-safe-tp21673971p21697036.html
Sent from the Muse User mailing list archive at Nabble.com.


Re: XsdUtils.getLocalTimeString not thread safe

Posted by Chris Twiner <ch...@gmail.com>.
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 <su...@yahoo.com> 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.
>
>