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

ValueRange.of(long, long, long) does not throw IAE on invalid inputs

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 15
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      IAE is now correctly thrown when (smallest) minimum is greater than smallest maximum. Applications that incorrectly set values for ValueRange will see this exception.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      java.time.temporal.ValueRange.of(long, long, long) should throw an InvalidArgumentException on invalid inputs. Similarly of(long, long, long, long) method should throw IAE appropriately.

      Problem

      of(min, maxSmallest, maxLargest) does not throw an IAE when min is greater than maxSmallest even though it is specified in the method description. The four-argument overload method also has this issue, as well as it lacks the IAE condition for "minSmallest > minLargest" on which the implementation is throwing the exception.

      Solution

      • of(min, maxSmallest, maxLargest) should throw an IAE when min is greater than maxSmallest.
      • of(minSmallest, minLargest, maxSmallest, maxLargest) should throw an IAE when minSmallest is greater than maxSmallest.
      • The method description for of(minSmallest, minLargest, maxSmallest, maxLargest) should describe the IAE condition for minSmallest is greater than minLargest.

      Specification

      The @throws clause in the method description for java.time.temporal.ValueRange.of(long, long, long, long) should change from:

        * @throws IllegalArgumentException if
        *     the smallest minimum is greater than the smallest maximum,
        *  or the smallest maximum is greater than the largest maximum
        *  or the largest minimum is greater than the largest maximum

      to:

       * @throws IllegalArgumentException if
       *     the smallest minimum is greater than the smallest maximum,
       *  or the smallest maximum is greater than the largest maximum,
       *  or the largest minimum is greater than the largest maximum,
       *  or the smallest minimum is greater than the largest minimum

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                naoto Naoto Sato
                Reporter:
                webbuggrp Webbug Group
                Reviewed By:
                Roger Riggs
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: