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

CharsetDecoder/Encoder's constructor does not reject NaN

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P5 P5
    • 12
    • core-libs
    • None
    • behavioral
    • minimal
    • NaN were not rejected, however it's extremely unlikely that any application relied on this behavior.
    • Java API
    • Implementation

      Summary

      The constructors of CharsetDecoder and CharsetEncoder do not reject some invalid arguments values.

      Problem

      Specification states that the constructors of CharsetDecoder and CharsetEncoder only accept positive float numbers, and IllegalArgumentException is thrown for invalid values. However, NaN values are not rejected.

      Solution

      The implementation of the constructors of CharsetDecoder and CharsetEncoder will be updated, so that IllegalArgumentException will be thrown if one or both arguments are NaN.

      -        if (average$ItypesPerOtype$ <= 0.0f)
      +        if (!(average$ItypesPerOtype$ > 0.0f))
                   throw new IllegalArgumentException("Non-positive "
                                                      + "average$ItypesPerOtype$");
      -        if (max$ItypesPerOtype$ <= 0.0f)
      +        if (!(max$ItypesPerOtype$ > 0.0f))
                   throw new IllegalArgumentException("Non-positive "
                                                      + "max$ItypesPerOtype$");

      Specification

      Specification does not change.

            igerasim Ivan Gerasimov
            igerasim Ivan Gerasimov
            Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: