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: adapt to introduction of java.time in gax #3200

Closed
wants to merge 4 commits into from
Closed
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 @@ -16,14 +16,15 @@

package com.google.cloud.spanner;

import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration;

import com.google.api.core.InternalApi;
import com.google.api.gax.tracing.ApiTracer;
import com.google.api.gax.tracing.BaseApiTracer;
import com.google.api.gax.tracing.MetricsTracer;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
import org.threeten.bp.Duration;

@InternalApi
public class CompositeTracer extends BaseApiTracer {
Expand Down Expand Up @@ -108,10 +109,8 @@ public void attemptCancelled() {
}

@Override
public void attemptFailed(Throwable error, Duration delay) {
for (ApiTracer child : children) {
child.attemptFailed(error, delay);
}
public void attemptFailed(Throwable error, org.threeten.bp.Duration delay) {
attemptFailedDuration(error, toJavaTimeDuration(delay));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.google.cloud.spanner;

import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
Expand Down Expand Up @@ -151,10 +152,15 @@ public void testAttemptFailed() {
RuntimeException error = new RuntimeException();
Duration delay = Duration.ofMillis(10);
compositeTracer.attemptFailed(error, delay);
verify(child1, times(1)).attemptFailed(error, delay);
verify(child2, times(1)).attemptFailed(error, delay);
verify(child3, times(1)).attemptFailed(error, delay);
verify(child4, times(1)).attemptFailed(error, delay);

// CompositeTracer's attemptFailed calls the attemptFailedDuration method. This was part of
// the java.time migration effort to move away from threetenbp. Verify that each child tracer
// calls attemptFailedDuration once.
java.time.Duration delayDuration = toJavaTimeDuration(delay);
verify(child1, times(1)).attemptFailedDuration(error, delayDuration);
verify(child2, times(1)).attemptFailedDuration(error, delayDuration);
verify(child3, times(1)).attemptFailedDuration(error, delayDuration);
verify(child4, times(1)).attemptFailedDuration(error, delayDuration);
}

@Test
Expand Down
Loading