diff --git a/util/src/test/java/io/kubernetes/client/util/wait/WaitTest.java b/util/src/test/java/io/kubernetes/client/util/wait/WaitTest.java index a1d1eafbdc..092ca117ad 100644 --- a/util/src/test/java/io/kubernetes/client/util/wait/WaitTest.java +++ b/util/src/test/java/io/kubernetes/client/util/wait/WaitTest.java @@ -46,10 +46,7 @@ void pollShutsDownExecutorThreadAfterReturning() throws InterruptedException { // After poll returns the executor must have been shut down, so its worker thread terminates. // Allow a short grace period for the interrupt/shutdown to take effect. - long deadline = System.currentTimeMillis() + 2000; - while (worker.isAlive() && System.currentTimeMillis() < deadline) { - Thread.sleep(10); - } + worker.join(2000); assertThat(worker.isAlive()) .as("Wait.poll must shut down its executor so the worker thread is not leaked")