Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4449148

[Fmt-Nu] DecimalFormat.parse is not thread-safe

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • 7
    • 1.3.0, 1.3.1, 1.3.1_02, 1.4.0
    • core-libs
    • generic, x86, sparc
    • generic, solaris_8, windows_2000



        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)
        ======================================================================

              okutsu Masayoshi Okutsu
              bonealsunw Bret O'neal (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: