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

DecimalFormat.setGroupingSize(int) allows setting negative grouping size

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 14
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      An exception is thrown for those invalid input values.
    • Interface Kind:
      Java API
    • Scope:
      JDK

      Description

      Summary

      The grouping size of DecimalFormat should not accept negative values.

      Problem

      grouping size is defined as:

      The grouping size is a constant number of digits between the grouping characters, such as 3 for 100,000,000 or 4 for 1,0000,0000.

      So it should not take a negative value. Also as it is cast to byte type, the size should not be greater than Byte.MAX_VALUE.

      Solution

      If an invalid value is specified in DecimalFormat.setGroupingSize(int), throw an IllegalArgumentException.

      Specification

      Add the following sentence in the last paragraph of the method description.

      * Invalid value, i.e., negative or greater than
      * {@link java.lang.Byte#MAX_VALUE Byte.MAX_VALUE}, will throw an
      * {@code IllegalArgumentException}.

      Add the following @throws sentence at the last of the method description.

      * @throws IllegalArgumentException if {@code newValue} is negative or
      *          greater than {@link java.lang.Byte#MAX_VALUE Byte.MAX_VALUE}

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              naoto Naoto Sato
              Reporter:
              nishjain Nishit Jain
              Reviewed By:
              Roger Riggs
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: