@@ -227,7 +227,7 @@ private <V> V performIteration(Function<? super T, V> isTrue, Instant start, Ins
227
227
long iterationNumber = 1 ;
228
228
Throwable lastException ;
229
229
230
- sleepUninterruptible (pollDelay );
230
+ sleepInterruptibly (pollDelay );
231
231
232
232
while (true ) {
233
233
try {
@@ -251,14 +251,16 @@ private <V> V performIteration(Function<? super T, V> isTrue, Instant start, Ins
251
251
}
252
252
253
253
Duration interval = getIntervalWithPollingStrategy (start , iterationNumber );
254
- sleepUninterruptible (interval );
254
+ sleepInterruptibly (interval );
255
255
256
256
++iterationNumber ;
257
257
}
258
258
}
259
259
260
260
private <V > void handleTimeoutException (Throwable lastException , Function <? super T , V > isTrue ) {
261
- String message = Optional .ofNullable (getMessageSupplier ()).map (Supplier ::get ).orElseGet (() -> "waiting for " + isTrue );
261
+ String message = Optional .ofNullable (getMessageSupplier ())
262
+ .map (Supplier ::get )
263
+ .orElseGet (() -> "waiting for " + isTrue );
262
264
263
265
String timeoutMessage = String .format (
264
266
"Expected condition failed: %s (tried for %s millis with an interval of %s millis)" ,
@@ -282,9 +284,9 @@ private Duration getIntervalWithPollingStrategy(Instant start, long iterationNum
282
284
.orElse (interval );
283
285
}
284
286
285
- private void sleepUninterruptible (Duration duration ) {
287
+ private void sleepInterruptibly (Duration duration ) {
286
288
try {
287
- if (!duration .isZero ()) {
289
+ if (!duration .isZero () && ! duration . isNegative () ) {
288
290
getSleeper ().sleep (duration );
289
291
}
290
292
} catch (InterruptedException e ) {
0 commit comments