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

[Fmt-De] NumberFormat able to parse wrongly formatted input

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • tbd
    • 6u25
    • core-libs
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.6.0_22"
      Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
      Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      If grouping separator is used NumberFormat parses even wrong inputs.
      Say we have grouping separator set to ',' and decimal separator to '. then the non-valid input '1,,,,,5.5' is fully parsed as 15.5 without any complains.

      By further analysis the problematic part lies in DecimalFormat.subparse method, it says it requires a digit after the grouping separator but if none comes and we have backed up last non-digit character nothing happens and the cycle goes on.




      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      NumberFormat nf = NumberFormat.getNumberInstance(Locale.ENGLISH);
          try {
            System.out.println(nf.parse("1,,,,5.5"));
          } catch (ParseException e) {
            e.printStackTrace();
          }
      ---------- END SOURCE ----------

            jlu Justin Lu
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: