commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Benedict (JIRA)" <>
Subject [jira] Commented: (LANG-367) FastDateFormat thread safety
Date Wed, 31 Oct 2007 04:39:50 GMT


Paul Benedict commented on LANG-367:

Based on this link:

"In any case, it's better to be clear in the documentation about how a class behaves when
an instance is shared across threads. As an example of this pitfall, the class java.text.SimpleDateFormat
is not thread-safe, but it wasn't until the 1.4 JDK that this was documented in the Javadoc.
How many developers mistakenly created a static instance of SimpleDateFormat and used it from
multiple threads, unaware that their programs were not going to behave correctly under heavy
load? Don't do this to your customers or colleagues!"

> FastDateFormat thread safety
> ----------------------------
>                 Key: LANG-367
>                 URL:
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 2.4
>         Attachments: FastDateFormat.patch
> FastDateFormat has several static HashMaps. These are currently not final, so there is
no guarantee that they will be visible to all threads.
> Patch to follow.
> Also, as far as I can make out, the class shares SimpleDateFormat instances between threads.
> It does not document why this is OK.
> I'm guessing that it assumes that instances of the SimpleDateFormat class are thread-safe
provided that they have the same attributes, but this is not documented. If this is the case,
it's not clear that it is a valid assumption.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message