JDK-8239520 : ValueRange.of(long, long, long) does not throw IAE on invalid inputs
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.time
  • Affected Version: 15
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2020-02-19
  • Updated: 2020-11-13
  • Resolved: 2020-02-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b12Fixed
Related Reports
CSR :  
Sub Tasks
JDK-8239882 :  
Description
A DESCRIPTION OF THE PROBLEM :
The javadoc for ValueRange.of(long min, long maxSmallest, long maxLargest) states that an exception will be thrown if the minimum is greater than the smallest maximum.  However, an exception only occurs if the minimum is greater than the largest maximum.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a ValueRange with the following parameters:
ValueRange vr = ValueRange.of(5, 2, 10);



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An IllegalArgumentException should be thrown
ACTUAL -
A ValueRange is returned, with a range of 5 - 2/10

---------- BEGIN SOURCE ----------
import java.time.temporal.ValueRange;
public class TestValueRange {
  public static void main(String[] args) {
    ValueRange vr = ValueRange.of(5, 2, 10);
    System.out.println(vr.toString());
  }
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
Informed the submitter download the fix from https://jdk.java.net/15/ and verify it.
15-07-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/be0c5da2d83f User: naoto Date: 2020-02-24 22:17:09 +0000
24-02-2020

It is not a doc bug, but the implementation is incorrect. Similarly, of(long, long, long, long) has both doc issue and impl. issue.
20-02-2020

Roger - not sure if this should be you or Naoto?
20-02-2020

Observation summary on Windows 10: JDK15: Failed to throw an IllegalArgumentException
20-02-2020