[BUG] Thread.sleep(1) + real-clock timestamp ordering assertion
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
## Description
`Thread.sleep(1)` then `assertThat(second.getLastHeartBeatTime(), greaterThan(firstBeat))` where the timestamp comes from `System.currentTimeMillis()`. On coarse-grained clocks (Windows ~15ms, loaded CI) 1ms does not guarantee a strictly-greater value.
## Location
```
shenyu-admin/src/test/java/org/apache/shenyu/admin/service/impl/InstanceCheckServiceTest.java:105-111
```
## Impact
Intermittent false failure on slow/coarse-clock runners.
## Suggested fix
Inject a controllable clock (or set the field reflectively to a fixed-then-incremented value); assert on the injected values, not wall clock.
## Related existing issue(s)
None
_Identified during the 2026-08-02 audit; full list in [`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at shenyu-admin/src/test/java/org/apache/shenyu/admin/service/impl/InstanceCheckServiceTest.java:105-111 and inspect how the timestamp is obtained from System.currentTimeMillis(). Replace the Thread.sleep(1) timing dependency with the suggested controllable-clock or fixed-then-incremented test setup. Done means the assertion uses deterministic injected values and no longer intermittently fails on coarse-clock or loaded CI runners.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100