I know that SimpleDateFormat and NumberFormat are NOT thread safe.
https://bugs.java.com/bugdatabase/view_bug?bug_id=4101500
But what about the other Format classes like MessageFormat?
Fortify 360 is flagging the use of "MessageFormat.format(String, Object…)" static method as a "Race Condition – Format Flaw" issue, but when I analyze the the source code of MessageFormat, I saw that in that method, it creates a new local instance of MessageFormat itself.
Is the Java MessageFormat Class thread safe?
The javadoc for
MessageFormatsays:So officially, no – it’s not thread-safe.
The docs for
SimpleDateFormatsay much the same thing.Now, the docs may just be being conservative, and in practice it’ll work just fine in multiple threads, but it’s not worth the risk.