JDK-8239574 : ValueRange.of(long, long, long) does not throw IAE on invalid inputs
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.time
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 15
  • Submitted: 2020-02-20
  • Updated: 2020-02-24
  • Resolved: 2020-02-24
Related Reports
CSR :  
Sub Tasks
JDK-8239881 :  
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


Comments
Thanks, Joe. Created a release note sub-task as suggested.
24-02-2020

Moving to Approved; please consider whether or not this merits a release note.
24-02-2020