java
system_error
ai_generated
true
java.lang.InterruptedException: sleep interrupted
ID: java/mockito-verify-timeout-interrupted
80%Fix Rate
81%Confidence
0Evidence
2024-11-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 8+ | active | — | — | — |
Root Cause
verify with timeout uses a background thread that gets interrupted, often due to test timeout or thread issues.
generic中文
带有超时的 verify 使用后台线程,该线程被中断,通常由于测试超时或线程问题。
Workarounds
-
85% success Increase test timeout to accommodate verify timeout
@Timeout(10) @Test void asyncTest() { verify(mock, timeout(5000)).method(); } -
90% success Use awaitility library for async tests
await().atMost(5, SECONDS).untilAsserted(() -> { verify(mock).method(); });
Dead Ends
Common approaches that don't work:
-
Removing timeout from verify
60% fail
May cause test to hang indefinitely.
-
Catching InterruptedException and ignoring
50% fail
Hides real threading issues; test may pass incorrectly.