[15] RFR: 8246261: TCKLocalTime.java failed due to "AssertionError: expected [18:14:22] but found [18:14:23]"

naoto.sato at oracle.com naoto.sato at oracle.com
Mon Jun 1 19:31:25 UTC 2020


Hello,

Please review the fix to the following issue:

https://bugs.openjdk.java.net/browse/JDK-8246261

The proposed changeset is located at:

https://cr.openjdk.java.net/~naoto/8246261/webrev.00/

The test case compares two LocalTime objects, created with 
LocalTime.now(Clock/ZoneId). So inherently those two objects could have 
different times. The test tries to compare them 100 times for the exact 
match, and if not, then falls back to compare those times by truncating 
nanoseconds. The failure could occur when those two LocalTimes are 
around the whole second, e.g., expected == 18:14:22.999999 and test == 
18:14:23.000001. To fix this, check the difference of those objects and 
ensure it is less than a second.

Similar test cases exist in TCKLocalDateTime.java and 
TCKZonedDateTime.java so they should also be fixed. It is ok to leave 
the similar test case in TCKLocalDate.java, as multiple tries do exact 
match.

Naoto


More information about the core-libs-dev mailing list