Skip to content

Commit 4192e08

Browse files
Claude4.0oclaude
andcommitted
Fix flaky UniqueIdGeneratorTest timing tests
- Increase threshold from 2ms to 50ms for testIDtoDate and testIDtoInstant - CI environments can have thread scheduling delays exceeding 2ms Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
1 parent 47015c8 commit 4192e08

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* **MAINTENANCE**: Fixed flaky `IOUtilitiesProtocolValidationTest.testProtocolValidationPerformance` test
55
* Added warmup iterations to allow JIT compilation before timing
66
* Increased threshold from 100ms to 500ms for CI environments with variable performance
7+
* **MAINTENANCE**: Fixed flaky `UniqueIdGeneratorTest` timing tests
8+
* Increased threshold from 2ms to 50ms for CI environments with thread scheduling delays
79

810
#### 4.90.0 2026-02-02
911
* **BUG FIX**: `DeepEquals` - URL comparison now uses string representation instead of `URL.equals()`

src/test/java/com/cedarsoftware/util/UniqueIdGeneratorTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ void testIDtoDate()
6666
{
6767
long id = getUniqueId();
6868
Date date = getDate(id);
69-
assert abs(date.getTime() - currentTimeMillis()) < 2;
69+
// Use generous threshold for CI environments with thread scheduling delays
70+
assert abs(date.getTime() - currentTimeMillis()) < 50;
7071

7172
id = getUniqueId19();
7273
date = getDate19(id);
73-
assert abs(date.getTime() - currentTimeMillis()) < 2;
74+
assert abs(date.getTime() - currentTimeMillis()) < 50;
7475
}
7576

7677
@Test
@@ -79,12 +80,13 @@ void testIDtoInstant()
7980
long id = getUniqueId();
8081
long currentTime = currentTimeMillis();
8182
Instant instant = getInstant(id);
82-
assert abs(instant.toEpochMilli() - currentTime) <= 2;
83+
// Use generous threshold for CI environments with thread scheduling delays
84+
assert abs(instant.toEpochMilli() - currentTime) <= 50;
8385

8486
id = getUniqueId19();
8587
instant = getInstant19(id);
8688
currentTime = currentTimeMillis();
87-
assert abs(instant.toEpochMilli() - currentTime) <= 2;
89+
assert abs(instant.toEpochMilli() - currentTime) <= 50;
8890
}
8991

9092
@Test

0 commit comments

Comments
 (0)