Skip to content

Commit edc5bbf

Browse files
committed
fix: prevent illegal negative timeout values into thread sleep() method while retrying exceptions in unit tests.
* For details on issue see - googleapis#2206
1 parent d566613 commit edc5bbf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITClosedSessionTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ public void testTransactionManager() throws InterruptedException {
251251
break;
252252
}
253253
} catch (AbortedException e) {
254-
Thread.sleep(e.getRetryDelayInMillis());
254+
long retryDelayInMillis = e.getRetryDelayInMillis();
255+
if(retryDelayInMillis > 0) {
256+
Thread.sleep(retryDelayInMillis);
257+
}
255258
txn = manager.resetForRetry();
256259
}
257260
}

0 commit comments

Comments
 (0)