diff --git a/README.md b/README.md
index 1e5ed6035..96122305f 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ If you are using Maven without the BOM, add this to your dependencies:
com.google.cloud
google-cloud-firestore
- 3.29.0
+ 3.29.1
```
diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java
index 5c7217141..4d532b459 100644
--- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java
+++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java
@@ -16,11 +16,13 @@
package com.google.cloud.firestore;
+import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration;
import static com.google.cloud.firestore.telemetry.TraceUtil.*;
import com.google.api.core.ApiClock;
import com.google.api.core.ApiFuture;
import com.google.api.core.NanoClock;
+import com.google.api.core.ObsoleteApi;
import com.google.api.core.SettableApiFuture;
import com.google.api.gax.rpc.ApiStreamObserver;
import com.google.api.gax.rpc.BidiStreamObserver;
@@ -52,7 +54,6 @@
import java.util.Random;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.threeten.bp.Duration;
/**
* Main implementation of the Firestore client. This is the entry point for all Firestore
@@ -500,9 +501,16 @@ public FirestoreRpc getClient() {
return firestoreClient;
}
+ /** This method is obsolete. Use {@link #getTotalRequestTimeoutDuration()} instead. */
+ @ObsoleteApi("Use getTotalRequestTimeoutDuration() instead")
@Override
- public Duration getTotalRequestTimeout() {
- return firestoreOptions.getRetrySettings().getTotalTimeout();
+ public org.threeten.bp.Duration getTotalRequestTimeout() {
+ return toThreetenDuration(getTotalRequestTimeoutDuration());
+ }
+
+ @Override
+ public java.time.Duration getTotalRequestTimeoutDuration() {
+ return firestoreOptions.getRetrySettings().getTotalTimeoutDuration();
}
@Override
diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreRpcContext.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreRpcContext.java
index 5207bd770..e25b47a43 100644
--- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreRpcContext.java
+++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreRpcContext.java
@@ -16,10 +16,13 @@
package com.google.cloud.firestore;
+import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration;
+
import com.google.api.core.ApiClock;
import com.google.api.core.ApiFuture;
import com.google.api.core.InternalApi;
import com.google.api.core.InternalExtensionOnly;
+import com.google.api.core.ObsoleteApi;
import com.google.api.gax.rpc.BidiStreamObserver;
import com.google.api.gax.rpc.BidiStreamingCallable;
import com.google.api.gax.rpc.ClientStream;
@@ -27,7 +30,6 @@
import com.google.api.gax.rpc.ServerStreamingCallable;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.firestore.spi.v1.FirestoreRpc;
-import org.threeten.bp.Duration;
@InternalApi
@InternalExtensionOnly
@@ -41,7 +43,13 @@ interface FirestoreRpcContext {
FirestoreRpc getClient();
- Duration getTotalRequestTimeout();
+ /** This method is obsolete. Use {@link #getTotalRequestTimeoutDuration()} instead. */
+ @ObsoleteApi("Use getTotalRequestTimeoutDuration() instead")
+ org.threeten.bp.Duration getTotalRequestTimeout();
+
+ default java.time.Duration getTotalRequestTimeoutDuration() {
+ return toJavaTimeDuration(getTotalRequestTimeout());
+ }
ApiClock getClock();
diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/StreamableQuery.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/StreamableQuery.java
index a959f9a15..6c6503aa4 100644
--- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/StreamableQuery.java
+++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/StreamableQuery.java
@@ -39,6 +39,7 @@
import com.google.firestore.v1.RunQueryResponse;
import com.google.protobuf.ByteString;
import io.grpc.Status;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -46,7 +47,6 @@
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.threeten.bp.Duration;
/**
* Represents a query whose results can be streamed. If the stream fails with a retryable error,
@@ -452,7 +452,7 @@ boolean shouldRetryQuery(
}
Duration duration = Duration.ofNanos(rpcContext.getClock().nanoTime() - startTimeNanos);
- return duration.compareTo(rpcContext.getTotalRequestTimeout()) < 0;
+ return duration.compareTo(rpcContext.getTotalRequestTimeoutDuration()) < 0;
}
/** Verifies whether the given exception is retryable based on the RunQuery configuration. */
diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/CompositeApiTracer.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/CompositeApiTracer.java
index 31dbddbbf..695b7c287 100644
--- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/CompositeApiTracer.java
+++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/CompositeApiTracer.java
@@ -16,13 +16,14 @@
package com.google.cloud.firestore.telemetry;
+import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration;
+
import com.google.api.gax.tracing.ApiTracer;
import com.google.api.gax.tracing.BaseApiTracer;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
-import org.threeten.bp.Duration;
/** Combines multiple {@link ApiTracer}s into a single {@link ApiTracer}. */
class CompositeApiTracer extends BaseApiTracer {
@@ -83,8 +84,8 @@ public void attemptCancelled() {
}
@Override
- public void attemptFailed(Throwable error, Duration delay) {
- children.forEach(child -> child.attemptFailed(error, delay));
+ public void attemptFailed(Throwable error, org.threeten.bp.Duration delay) {
+ attemptFailedDuration(error, toJavaTimeDuration(delay));
}
@Override
diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/EnabledTraceUtil.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/EnabledTraceUtil.java
index b0eeeca21..334bdfffb 100644
--- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/EnabledTraceUtil.java
+++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/EnabledTraceUtil.java
@@ -99,7 +99,7 @@ public ApiFunction getChannelConfi
// ends in `s` to indicate seconds and is preceded by the number of seconds, with nanoseconds
// expressed as fractional
// seconds.
- String durationString(org.threeten.bp.Duration duration) {
+ String durationString(java.time.Duration duration) {
int nanos = duration.getNano();
long seconds = duration.getSeconds();
int numLeadingZeros = 9;
@@ -330,10 +330,12 @@ private SpanBuilder addSettingsAttributesToCurrentSpan(SpanBuilder spanBuilder)
Attributes.builder()
.put(
ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.initial_retry_delay",
- durationString(firestoreOptions.getRetrySettings().getInitialRetryDelay()))
+ durationString(
+ firestoreOptions.getRetrySettings().getInitialRetryDelayDuration()))
.put(
ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.max_retry_delay",
- durationString(firestoreOptions.getRetrySettings().getMaxRetryDelay()))
+ durationString(
+ firestoreOptions.getRetrySettings().getMaxRetryDelayDuration()))
.put(
ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.retry_delay_multiplier",
String.valueOf(firestoreOptions.getRetrySettings().getRetryDelayMultiplier()))
@@ -342,16 +344,18 @@ private SpanBuilder addSettingsAttributesToCurrentSpan(SpanBuilder spanBuilder)
String.valueOf(firestoreOptions.getRetrySettings().getMaxAttempts()))
.put(
ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.initial_rpc_timeout",
- durationString(firestoreOptions.getRetrySettings().getInitialRpcTimeout()))
+ durationString(
+ firestoreOptions.getRetrySettings().getInitialRpcTimeoutDuration()))
.put(
ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.max_rpc_timeout",
- durationString(firestoreOptions.getRetrySettings().getMaxRpcTimeout()))
+ durationString(
+ firestoreOptions.getRetrySettings().getMaxRpcTimeoutDuration()))
.put(
ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.rpc_timeout_multiplier",
String.valueOf(firestoreOptions.getRetrySettings().getRpcTimeoutMultiplier()))
.put(
ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.total_timeout",
- durationString(firestoreOptions.getRetrySettings().getTotalTimeout()))
+ durationString(firestoreOptions.getRetrySettings().getTotalTimeoutDuration()))
.build());
}
diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/LocalFirestoreHelper.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/LocalFirestoreHelper.java
index 5ccd9f163..500e35ff9 100644
--- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/LocalFirestoreHelper.java
+++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/LocalFirestoreHelper.java
@@ -71,6 +71,7 @@
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
@@ -88,14 +89,13 @@
import org.mockito.ArgumentMatchers;
import org.mockito.stubbing.Answer;
import org.mockito.stubbing.Stubber;
-import org.threeten.bp.Duration;
public final class LocalFirestoreHelper {
protected static RetrySettings IMMEDIATE_RETRY_SETTINGS =
RetrySettings.newBuilder()
- .setInitialRetryDelay(Duration.ZERO)
- .setMaxRetryDelay(Duration.ZERO)
+ .setInitialRetryDelayDuration(Duration.ZERO)
+ .setMaxRetryDelayDuration(Duration.ZERO)
.setRetryDelayMultiplier(1)
.setJittered(false)
.build();
diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryCountTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryCountTest.java
index 78222ecfa..b6e91c291 100644
--- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryCountTest.java
+++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryCountTest.java
@@ -41,6 +41,7 @@
import com.google.firestore.v1.RunAggregationQueryResponse;
import com.google.firestore.v1.StructuredQuery;
import io.grpc.Status;
+import java.time.Duration;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
@@ -50,7 +51,6 @@
import org.mockito.Captor;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
-import org.threeten.bp.Duration;
@RunWith(MockitoJUnitRunner.class)
public class QueryCountTest {
@@ -70,7 +70,7 @@ public class QueryCountTest {
@Before
public void before() {
- doReturn(Duration.ZERO).when(firestoreMock).getTotalRequestTimeout();
+ doReturn(Duration.ZERO).when(firestoreMock).getTotalRequestTimeoutDuration();
query = firestoreMock.collection(COLLECTION_ID);
}
@@ -230,7 +230,7 @@ public void shouldNotRetryIfExceptionIsFirestoreExceptionWithNonRetryableStatus(
public void
shouldRetryIfExceptionIsFirestoreExceptionWithRetryableStatusWithInfiniteTimeoutWindow()
throws Exception {
- doReturn(Duration.ZERO).when(firestoreMock).getTotalRequestTimeout();
+ doReturn(Duration.ZERO).when(firestoreMock).getTotalRequestTimeoutDuration();
doAnswer(countQueryResponse(new FirestoreException("reason", Status.INTERNAL)))
.doAnswer(countQueryResponse(42))
.when(firestoreMock)
@@ -245,7 +245,7 @@ public void shouldNotRetryIfExceptionIsFirestoreExceptionWithNonRetryableStatus(
@Test
public void shouldRetryIfExceptionIsFirestoreExceptionWithRetryableStatusWithinTimeoutWindow()
throws Exception {
- doReturn(Duration.ofDays(999)).when(firestoreMock).getTotalRequestTimeout();
+ doReturn(Duration.ofDays(999)).when(firestoreMock).getTotalRequestTimeoutDuration();
doAnswer(countQueryResponse(new FirestoreException("reason", Status.INTERNAL)))
.doAnswer(countQueryResponse(42))
.when(firestoreMock)
@@ -267,7 +267,7 @@ public void shouldRetryIfExceptionIsFirestoreExceptionWithRetryableStatusWithinT
.doReturn(TimeUnit.SECONDS.toNanos(30))
.when(clockMock)
.nanoTime();
- doReturn(Duration.ofSeconds(5)).when(firestoreMock).getTotalRequestTimeout();
+ doReturn(Duration.ofSeconds(5)).when(firestoreMock).getTotalRequestTimeoutDuration();
doAnswer(countQueryResponse(new FirestoreException("reason", Status.INTERNAL)))
.doAnswer(countQueryResponse(42))
.when(firestoreMock)
diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryTest.java
index 280c6e02a..78591cdda 100644
--- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryTest.java
+++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryTest.java
@@ -67,6 +67,7 @@
import io.grpc.Status;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -82,7 +83,6 @@
import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
-import org.threeten.bp.Duration;
@RunWith(MockitoJUnitRunner.class)
public class QueryTest {
@@ -123,7 +123,7 @@ public long millisTime() {
public void before() {
clock = new MockClock();
doReturn(clock).when(firestoreMock).getClock();
- doReturn(Duration.ZERO).when(firestoreMock).getTotalRequestTimeout();
+ doReturn(Duration.ZERO).when(firestoreMock).getTotalRequestTimeoutDuration();
query = firestoreMock.collection(COLLECTION_ID);
}
@@ -1130,7 +1130,7 @@ public void retriesWithoutTimeout() throws Exception {
@Test
public void doesNotRetryWithTimeout() {
- doReturn(Duration.ofMinutes(1)).when(firestoreMock).getTotalRequestTimeout();
+ doReturn(Duration.ofMinutes(1)).when(firestoreMock).getTotalRequestTimeoutDuration();
doAnswer(
invocation -> {
diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java
index c84d00a19..0281f58a9 100644
--- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java
+++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java
@@ -84,6 +84,7 @@
import io.grpc.Status;
import io.grpc.Status.Code;
import io.grpc.StatusRuntimeException;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -106,7 +107,6 @@
import org.junit.rules.TestName;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-import org.threeten.bp.Duration;
@RunWith(JUnit4.class)
public class ITSystemTest extends ITBaseTest {
@@ -2281,9 +2281,9 @@ public void testEnforcesTimeouts() {
FirestoreOptions.newBuilder()
.setRetrySettings(
RetrySettings.newBuilder()
- .setMaxRpcTimeout(Duration.ofMillis(1))
- .setTotalTimeout(Duration.ofMillis(1))
- .setInitialRpcTimeout(Duration.ofMillis(1))
+ .setMaxRpcTimeoutDuration(Duration.ofMillis(1))
+ .setTotalTimeoutDuration(Duration.ofMillis(1))
+ .setInitialRpcTimeoutDuration(Duration.ofMillis(1))
.build())
.build();
firestore = firestoreOptions.getService();
diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/telemetry/EnabledTraceUtilTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/telemetry/EnabledTraceUtilTest.java
index 22e835f19..d3fb7e216 100644
--- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/telemetry/EnabledTraceUtilTest.java
+++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/telemetry/EnabledTraceUtilTest.java
@@ -22,9 +22,9 @@
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.trace.TracerProvider;
import io.opentelemetry.sdk.OpenTelemetrySdk;
+import java.time.Duration;
import org.junit.Before;
import org.junit.Test;
-import org.threeten.bp.Duration;
public class EnabledTraceUtilTest {
@Before