Bug 44887 - Thread Safety Problem with FOP 0.93
Summary: Thread Safety Problem with FOP 0.93
Status: RESOLVED FIXED
Alias: None
Product: XMLGraphicsCommons - Now in Jira
Classification: Unclassified
Component: xmp (show other bugs)
Version: Trunk
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: --
Assignee: XML Graphics Project Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-28 01:52 UTC by Jean-Claude Rouvinez
Modified: 2008-06-18 07:10 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Claude Rouvinez 2008-04-28 01:52:41 UTC
Hi,

We use the version 0.93 of FOP.
When this library is used in a Multi Threaded environment, we receive the following error message:

         java.lang.Thread.run(Thread.java:595)
            Caused by: <java.lang.NumberFormatException: For input string: "E444444411E411EEEEEE1">
            sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1224)
            java.lang.Double.parseDouble(Double.java:482)
            java.text.DigitList.getDouble(DigitList.java:141)
            java.text.DecimalFormat.parse(DecimalFormat.java:1276)
            java.text.SimpleDateFormat.subParse(SimpleDateFormat.java:1375)
            java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1124)
            java.text.DateFormat.parse(DateFormat.java:333)
            org.apache.xmlgraphics.xmp.XMPSchemaAdapter.parseISO8601Date(XMPSchemaAdapter.java:189)

The reason is the use of a DateFormat as static class variable:
http://svn.apache.org/viewvc/xmlgraphics/commons/tags/commons-1_1/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java?view=markup

The JAVA DateFormat classes are not at all thread safe. This is written in the API description: <Date formats are not synchronized>.

On your site http://xmlgraphics.apache.org/fop/0.94/embedding.html#multithreading
you write:
 <If you encounter any suspicious behaviour, please notify us.>

I hope that the notification of this problem will help you.

Best Regards
Jean-Claude
Comment 1 Jeremias Maerki 2008-04-28 08:27:03 UTC
Yeah, we know that we use the date and number format classes in a not so good way but so far I can't remember a bug report before. I'm just curious: what Java VM, operating system and CPU are you using?

I'll look into this and try to find a better solution. I guess while we're at it we'll have to fix similar misuses in FOP, too.
Comment 2 Jeremias Maerki 2008-04-29 23:17:58 UTC
The issue in XG Commons should be fixed now:
http://svn.apache.org/viewvc?rev=652284&view=rev

I'll keep this issue open until I've fixed similar problems in FOP, too.
Comment 3 Jean-Claude Rouvinez 2008-05-02 02:33:06 UTC
$ java -version
java version "1.5.0_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode)

Intel(R)
Pentium(R) 4 CPU 2.80GHz
2.79GHz, 1.99 GB RAM

Microsoft Windows XP
Professional
Version 2002
Service Pack 2
Comment 4 Jeremias Maerki 2008-06-18 07:10:56 UTC
Problematic uses of DecimalFormat now fixed in 0.95 branch of FOP, too:
http://svn.apache.org/viewvc?rev=669173&view=rev