Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent illegal negative timeout values into thread sleep() method in ITTransactionManagerTest. #2715

Merged
merged 12 commits into from
Oct 31, 2023
Merged
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ If you are using Maven without the BOM, add this to your dependencies:
If you are using Gradle 5.x or later, add this to your dependencies:

```Groovy
implementation platform('com.google.cloud:libraries-bom:26.25.0')
implementation platform('com.google.cloud:libraries-bom:26.26.0')

implementation 'com.google.cloud:google-cloud-spanner'
```
Original file line number Diff line number Diff line change
@@ -134,7 +134,10 @@ public void simpleInsert() throws InterruptedException {
assertThat(row.getBoolean(1)).isTrue();
break;
} catch (AbortedException e) {
Thread.sleep(e.getRetryDelayInMillis());
long retryDelayInMillis = e.getRetryDelayInMillis();
if (retryDelayInMillis > 0) {
Thread.sleep(retryDelayInMillis);
}
txn = manager.resetForRetry();
}
}
@@ -158,7 +161,10 @@ public void invalidInsert() throws InterruptedException {
manager.commit();
fail("Expected exception");
} catch (AbortedException e) {
Thread.sleep(e.getRetryDelayInMillis());
long retryDelayInMillis = e.getRetryDelayInMillis();
if (retryDelayInMillis > 0) {
Thread.sleep(retryDelayInMillis);
}
txn = manager.resetForRetry();
} catch (SpannerException e) {
// expected
@@ -188,7 +194,10 @@ public void rollback() throws InterruptedException {
manager.rollback();
break;
} catch (AbortedException e) {
Thread.sleep(e.getRetryDelayInMillis());
long retryDelayInMillis = e.getRetryDelayInMillis();
if (retryDelayInMillis > 0) {
Thread.sleep(retryDelayInMillis);
}
txn = manager.resetForRetry();
}
}
@@ -231,7 +240,10 @@ public void abortAndRetry() throws InterruptedException {
manager1.commit();
break;
} catch (AbortedException e) {
Thread.sleep(e.getRetryDelayInMillis());
long retryDelayInMillis = e.getRetryDelayInMillis();
if (retryDelayInMillis > 0) {
Thread.sleep(retryDelayInMillis);
}
// It is possible that it was txn2 that aborted.
// In that case we should just retry without resetting anything.
if (manager1.getState() == TransactionState.ABORTED) {
@@ -278,7 +290,10 @@ public void testTransactionManagerReturnsCommitStats() throws InterruptedExcepti
assertEquals(2L, manager.getCommitResponse().getCommitStats().getMutationCount());
break;
} catch (AbortedException e) {
Thread.sleep(e.getRetryDelayInMillis());
long retryDelayInMillis = e.getRetryDelayInMillis();
if (retryDelayInMillis > 0) {
Thread.sleep(retryDelayInMillis);
}
transaction = manager.resetForRetry();
}
}