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

ChoiceFormat::applyPattern inconsistency for invalid patterns

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 23
    • 7, 22
    • core-libs
    • b13
    • generic
    • generic
    • Verified

      FULL PRODUCT VERSION :
      java version "1.6.0_0"
      IcedTea6 1.4-ra530e095f65b Runtime Environment (build 1.6.0_0-b14)
      OpenJDK 64-Bit Server VM (build 14.0-b08, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux rivendell 2.6.27-gentoo-r7.rivendell #3 SMP Mon Dec 29 06:59:33 GMT 2008 x86_64 Intel(R) Xeon(R) CPU X5482 @ 3.20GHz GenuineIntel GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      The documentation for java.text.ChoiceFormat doesn't give any syntax for the possible patterns or specify than an exception is thrown if an invalid pattern is passed to the constructor or applyPattern.

      In practice, the following behaviour is in evidence:

      new ChoiceFormat("0#zero|1#one|1>many")

      silently completes, yielding formats ["zero","one"] and limits [0,1]. The invalid "1>many" is just dropped. We can assume from this that '>' is unrecognised (the correct version is 1<many).

      new ChoiceFormat("0#zero|1#one|1>many|")

      again silently completes, yielding formats ["zero","one",""] and limits [0,1,1].

      new ChoiceFormat("0#zero|1#one|1>many|1<many")

      throws an IllegalArgumentException.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the test cases specified above.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      All three invalid patterns should throw IllegalArgumentException.
      ACTUAL -
      The first two pass silently, returning a ChoiceFormat. The first ChoiceFormat contains valid data, having simply dropped the invalid format. The second contains a spurious pair of an empty string and the value 1 as a limit.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      See the Mauve (http://sources.redhat.com/mauve) testcase gnu/testlet/java/text/ChoiceFormat/Bad.java
      ---------- END SOURCE ----------

            jlu Justin Lu
            robilad Dalibor Topic
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: