Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static <T> T runTxWithRetriesOnAborted(Callable<T> callable) {
static <T> T runTxWithRetriesOnAborted(Callable<T> callable, RetrySettings retrySettings) {
try {
return RetryHelper.runWithRetries(
callable, txRetrySettings, new TxRetryAlgorithm<>(), NanoClock.getDefaultClock());
callable, retrySettings, new TxRetryAlgorithm<>(), NanoClock.getDefaultClock());
} catch (RetryHelperException e) {
if (e.getCause() != null) {
Throwables.throwIfUnchecked(e.getCause());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,18 @@ public Integer call() throws Exception {

@Test
public void testExceptionWithRetryInfo() {
final int RETRY_DELAY_NANOS = 100_000_000;
final int RETRY_DELAY_MILLIS = 100;
Metadata.Key<RetryInfo> key = ProtoUtils.keyForProto(RetryInfo.getDefaultInstance());
Status status = Status.fromCodeValue(Status.Code.ABORTED.value());
Metadata trailers = new Metadata();
RetryInfo retryInfo =
RetryInfo.newBuilder()
.setRetryDelay(Duration.newBuilder().setNanos(RETRY_DELAY_NANOS).build())
.setRetryDelay(
Duration.newBuilder()
.setNanos(
(int)
TimeUnit.NANOSECONDS.convert(RETRY_DELAY_MILLIS, TimeUnit.MILLISECONDS))
.build())
.build();
trailers.put(key, retryInfo);
final SpannerException e =
Expand All @@ -214,8 +219,8 @@ public Integer call() throws Exception {
// retry info of the exception.
Stopwatch watch = Stopwatch.createStarted();
assertThat(SpannerRetryHelper.runTxWithRetriesOnAborted(callable)).isEqualTo(2);
long elapsed = watch.elapsed(TimeUnit.NANOSECONDS);
assertThat(elapsed >= RETRY_DELAY_NANOS).isTrue();
long elapsed = watch.elapsed(TimeUnit.MILLISECONDS);
assertThat(elapsed >= RETRY_DELAY_MILLIS).isTrue();
}

private SpannerException abortedWithRetryInfo(int nanos) {
Expand Down