JDK-4449148 : [Fmt-Nu] DecimalFormat.parse is not thread-safe
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 1.3.0,1.3.1,1.3.1_02,1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,solaris_8,windows_2000
  • CPU: generic,x86,sparc
  • Submitted: 2001-04-22
  • Updated: 2008-06-23
  • Resolved: 2008-06-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 7
1.3.1Resolved 7Resolved
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description

Name: boT120536			Date: 04/22/2001


Here is source code version:

/*
 * @(#)DecimalFormat.java	1.57 00/01/19
 *
 * Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved.
 *
 * This software is the proprietary information of Sun Microsystems, Inc.
 * Use is subject to license terms.
 *
 */



The routing java.text.DecimalFormat is not thread safe.

We are facing problems when concurrent accesses are done to a single
SimpleDateFormat for parsing a date with format "yyMMddHHmmss".


The stack trace is:

java.lang.NumberFormatException:
   at java.lang.Long.parseLong(Long.java:331)
   at java.lang.Long.parseLong(Long.java:363)
   at java.text.DigitList.getLong(DigitList.java:153)
   at java.text.DecimalFormat.parse(DecimalFormat.java:808)
   at java.text.SimpleDateFormat.subparse(SimpleDateFormat.java:987)
   at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:708)
   ...


After many investigations and examination of Java core libray source code as
provided with JBuilder Entreprise edition 4.0, I reached the following
diagnostic.

The accesses to the private 'digitList' field should be protected through
critical section. It is the case at line 441 and 498 in DecimalFormat.java

However, there is a LACK of critical section between line 793 (which is setting
digitList) and line 808 (which is using it). It should guarranteed that no
acces can be performed by a concurrentely running thread that would reset or
modify the digitList field betwezen those lines.
(Review ID: 120972) 
======================================================================

Comments
EVALUATION The java.text.Format subclasses aren't thread-safe by design. Closing as a duplicate of 4264153.
23-06-2008

WORK AROUND Name: boT120536 Date: 04/22/2001 No concurrent access to a single SimpleDateFormat object. ======================================================================
02-09-2004

EVALUATION Bug# 4101500 states that NumberFormat was fixed to be thread-safe. However, there was an oversight in the 4101500 fix. DecimalFormat.parse() needs to be synchronized with digitList. On the other hand, the API doc was changed as the 4264153 fix to state the Format subclasses are not thread-safe. This is very confusing and we should fix this bug or back out the partial 4101500 fix. ###@###.### 2002-10-15
15-10-2002