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

feat: Introduce java.time to Gax-Java #1872

Merged
merged 158 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
158 commits
Select commit Hold shift + click to select a range
212dcfa
chore: initial conversion to java.time in gax production classes
diegomarquezp Jul 18, 2023
62ae4ef
chore: initial conversion to java.time in gax test classes
diegomarquezp Jul 20, 2023
484fd74
chore: use java.time conversion util
diegomarquezp Jul 20, 2023
455b61b
chore: fmt
diegomarquezp Jul 20, 2023
c5eee47
chore: restore mistake in search/replace
diegomarquezp Jul 20, 2023
ef83e0d
chore: ignore java time / threeten differences
diegomarquezp Jul 20, 2023
ee31831
chore: adapt tests
diegomarquezp Jul 20, 2023
f6b3fd7
chore: adapt tests
diegomarquezp Jul 20, 2023
b50b585
Merge branch 'threeten-deprecation-gax' into threeten-deprecation
diegomarquezp Jul 20, 2023
521c8fb
chore: fix expected output using Duration in tests
diegomarquezp Jul 20, 2023
63b882d
chore: fix clirr in other projects
diegomarquezp Jul 20, 2023
774139a
chore: internal usage of java.time in gax
diegomarquezp Jul 26, 2023
0be22ab
chore: adapt builder of `retrying`
diegomarquezp Jul 26, 2023
03a9f65
chore: adapt builders in `gax`
diegomarquezp Jul 27, 2023
523d100
chore: adapt builders in `gax-grpc`
diegomarquezp Jul 27, 2023
43f3077
chore: adapt builders in `gax-httpjson`
diegomarquezp Jul 27, 2023
d4d1428
feat: Introduce @ObsoleteApi
blakeli0 Jul 27, 2023
e261058
chore: format
blakeli0 Jul 27, 2023
490b214
Update api-common-java/src/main/java/com/google/api/core/ObsoleteApi.…
blakeli0 Jul 27, 2023
a1a0136
Update api-common-java/src/main/java/com/google/api/core/ObsoleteApi.…
blakeli0 Jul 27, 2023
8fda898
chore: format
blakeli0 Jul 27, 2023
7879446
chore: Rename value to description.
blakeli0 Jul 27, 2023
5e2c20e
doc: Add a blurb in README.md
blakeli0 Jul 28, 2023
3945a98
doc: Update wording.
blakeli0 Jul 29, 2023
5e9c638
doc: Update wording.
blakeli0 Jul 31, 2023
0b5d5e6
doc: Update wording.
blakeli0 Jul 31, 2023
2e07a48
chore: rename description to value.
blakeli0 Jul 31, 2023
e6c20b7
chore: adapt builders in `google-cloud-core`
diegomarquezp Jul 27, 2023
d7b0cf3
chore: format
diegomarquezp Aug 1, 2023
5cf1289
chore: fix tests in gax/gax
diegomarquezp Aug 1, 2023
44b45d3
Merge remote-tracking branch 'origin/add-obsolete-api' into threeten-…
diegomarquezp Aug 1, 2023
8e221c1
chore: add @ObsoleteApi annotation
diegomarquezp Aug 1, 2023
667f2da
chore: revert changes in gapic-generator-java
diegomarquezp Aug 1, 2023
6113cea
chore: changes in `Instant`
diegomarquezp Aug 1, 2023
9992618
chore: use java.time methods on builders
diegomarquezp Aug 3, 2023
e8a871b
chore: restore `RetrySettingsComposer`
diegomarquezp Aug 3, 2023
fbad4ee
Merge remote-tracking branch 'origin/main' into threeten-deprecation
diegomarquezp Aug 9, 2023
751ba06
Merge remote-tracking branch 'origin/main' into threeten-deprecation
diegomarquezp Aug 23, 2023
e20f974
chore: use local repository for api-common
diegomarquezp Aug 25, 2023
f05f2ef
chore: use local repository
diegomarquezp Aug 28, 2023
1cf298c
Merge remote-tracking branch 'origin/main' into threeten-deprecation
diegomarquezp Oct 25, 2023
4703dcd
format source
diegomarquezp Oct 25, 2023
4635dd5
add test for retry settings propagation
diegomarquezp Oct 25, 2023
7774eb0
restore bazel configurations
diegomarquezp Oct 25, 2023
63261fa
rename time objects test
diegomarquezp Oct 25, 2023
ba456a1
add generic test for time modifier methods
diegomarquezp Oct 25, 2023
2330496
Merge remote-tracking branch 'origin/main' into threeten-deprecation
diegomarquezp May 3, 2024
23c9ac4
Merge branch 'main' into threeten-deprecation
diegomarquezp May 3, 2024
6920222
post-merge fixes
diegomarquezp May 3, 2024
0c8ac5d
add tests for GrpcCallContext
diegomarquezp May 4, 2024
0c8cfb7
add tests for InstantiatingGrpcChannelProvider
diegomarquezp May 4, 2024
f9750ce
add HttpJsonCallContext tests
diegomarquezp May 5, 2024
351f829
modify tests for GrpcCallContext
diegomarquezp May 5, 2024
1be5153
modify InstantiatingGrpcChannelProvider test
diegomarquezp May 5, 2024
f84b521
add tests for HttpJsonCallOptions
diegomarquezp May 5, 2024
31ab5e0
rename to testDurationMethod()
diegomarquezp May 5, 2024
8fc424d
reformat
diegomarquezp May 5, 2024
c3bc83f
add annotation based test for autovalue classes
diegomarquezp May 6, 2024
16fa545
add reflection test for httpjson
diegomarquezp May 6, 2024
4fd48d4
adapt tests of ThresholdBatcher
diegomarquezp May 6, 2024
5dca441
add test for RetrySettings
diegomarquezp May 6, 2024
a58f1bf
use custom annotation for autovalues with default test values
diegomarquezp May 6, 2024
fc2ee3b
Revert "use custom annotation for autovalues with default test values"
diegomarquezp May 6, 2024
6576921
Revert "add test for RetrySettings"
diegomarquezp May 6, 2024
aa11c88
Revert "adapt tests of ThresholdBatcher"
diegomarquezp May 6, 2024
203960a
Revert "add reflection test for httpjson"
diegomarquezp May 6, 2024
5c07021
Revert "add annotation based test for autovalue classes"
diegomarquezp May 6, 2024
6c15c4c
simplify test helpers
diegomarquezp May 6, 2024
e48decf
add tests for HttpJsonCallOptions
diegomarquezp May 7, 2024
7c8a644
add tests for BatchingSettingsTest
diegomarquezp May 7, 2024
21e4240
add test for ThresholdBatcher
diegomarquezp May 7, 2024
8d96c61
add tests for retry settings
diegomarquezp May 7, 2024
eefff2a
chore: reformat
diegomarquezp May 7, 2024
233ce62
add tests for TimedAttemptSettings
diegomarquezp May 7, 2024
f55cf09
fix HttpJsonClientCall test
diegomarquezp May 8, 2024
6b437c1
add license headers to tests
diegomarquezp May 8, 2024
11043d4
add tests for ClientContext
diegomarquezp May 8, 2024
d3ebac5
add tests for ClientSettings
diegomarquezp May 8, 2024
50b0ffd
add tests for FixedWatchdogProvider
diegomarquezp May 8, 2024
21c03bd
fix internal java.time methods in WatchDog related classes
diegomarquezp May 8, 2024
16933f0
add tests for ServerStreamingCallSettings
diegomarquezp May 8, 2024
33a42bd
add tests for StubSettings
diegomarquezp May 8, 2024
bca5067
add test for UnaryCallSettings
diegomarquezp May 8, 2024
c1b91ee
reformat settings test
diegomarquezp May 8, 2024
173dc2e
add tests in tracing
diegomarquezp May 8, 2024
c8dc5f0
Merge branch 'main' into threeten-deprecation
diegomarquezp May 8, 2024
6abced3
remove unnecessary mocks
diegomarquezp May 8, 2024
31792f7
add license for metrics test utils
diegomarquezp May 8, 2024
a67cca5
add clirr ignore for api tracer
diegomarquezp May 8, 2024
a87d2b8
rename overloaded setters in ApiContext
diegomarquezp May 8, 2024
3b3d45a
rename overload method in InstantiatingGrpcChannelProvider
diegomarquezp May 8, 2024
eea294e
fix obsolete api annotations in apicallcontext
diegomarquezp May 8, 2024
48cd5e9
rename overload of HttpJsonCallOptions
diegomarquezp May 8, 2024
060c1fa
rename overload of BatchingSettings
diegomarquezp May 8, 2024
67000c7
modify overload of ThresholdBatcher
diegomarquezp May 8, 2024
9266ad0
fix wrong getter name in exp retry algo
diegomarquezp May 8, 2024
4ee554f
modify overloads in RetrySettings
diegomarquezp May 8, 2024
75668a5
modify overloads in TimedAttemptSettings
diegomarquezp May 8, 2024
964625f
modify overloads of ClientContext
diegomarquezp May 8, 2024
1c0df23
modify overloads in ClientSettings
diegomarquezp May 8, 2024
53d2131
modify overloads for watchdogs
diegomarquezp May 8, 2024
587f060
modify overloads of ServerStreamingCallSettings
diegomarquezp May 8, 2024
427d295
modify overloads of StubSettings
diegomarquezp May 9, 2024
9f51822
modify overloads for UnaryCallSettings
diegomarquezp May 9, 2024
2a4949b
modify overloads in ApiTracer
diegomarquezp May 9, 2024
60a43dd
reformat
diegomarquezp May 9, 2024
24c1566
reset java-core and showcase to main
diegomarquezp May 9, 2024
786c915
remove showcase IT
diegomarquezp May 9, 2024
a99d3c1
fix clirr and compilation
diegomarquezp May 9, 2024
7e64fc1
fix compileation issues
diegomarquezp May 9, 2024
75d038c
fix comments
diegomarquezp May 9, 2024
582668c
Merge remote-tracking branch 'origin/main' into threeten-deprecation
diegomarquezp May 9, 2024
f252f95
Merge remote-tracking branch 'origin/main' into threeten-deprecation
diegomarquezp May 11, 2024
f450e33
Revert "remove showcase IT"
diegomarquezp May 11, 2024
b276f07
reformat showcase test
diegomarquezp May 11, 2024
bd273a5
use java.time internal variables
diegomarquezp May 11, 2024
3c9edbb
Merge branch 'main' into threeten-deprecation
diegomarquezp May 13, 2024
d999fe3
Merge remote-tracking branch 'origin/threeten-deprecation' into three…
diegomarquezp May 29, 2024
5dbff0f
remove overloads for deprecated method in HttpJsonCallContext
diegomarquezp May 29, 2024
a579c0d
Add overload for Watchdog.create
diegomarquezp May 29, 2024
6755cb8
remove InternalApi from WatchdogProvider
diegomarquezp May 29, 2024
5d3df79
Noop for ApiTracer.attemptFailed
diegomarquezp May 29, 2024
175aeb3
Noop for BaseApiTracer.attemptFailed
diegomarquezp May 29, 2024
f9ece6f
remove testing getters in ThresholdBatcher
diegomarquezp May 29, 2024
02833c3
format
diegomarquezp May 29, 2024
389a520
suggest alternative method in javadoc
diegomarquezp Jun 6, 2024
5d945b3
more javadoc editions
diegomarquezp Jun 6, 2024
a21c678
fix public methods in Watchdog
diegomarquezp Jun 6, 2024
f17747b
Merge remote-tracking branch 'origin/main' into threeten-deprecation
diegomarquezp Jun 6, 2024
ed838ad
format
diegomarquezp Jun 6, 2024
5b51530
clirr fixes
diegomarquezp Jun 6, 2024
7091186
correct import
diegomarquezp Jun 6, 2024
3f7ac57
correct interface usage
diegomarquezp Jun 6, 2024
a23c041
Merge branch 'threeten-deprecation' of https://github.com/googleapis/…
diegomarquezp Jun 6, 2024
2158334
fix junit imports
diegomarquezp Jun 6, 2024
98fdeb3
add default behavior to WatchdogProvider
diegomarquezp Jun 6, 2024
7604897
fix IT
diegomarquezp Jun 6, 2024
4976270
Merge remote-tracking branch 'origin/threeten-deprecation' into three…
diegomarquezp Jun 6, 2024
59c4dbb
increase coverate in AttemptCallableTest
diegomarquezp Jun 6, 2024
8bbf01f
add tests for BaseApiTracer
diegomarquezp Jun 6, 2024
038d16b
increase coverage for BasicRetryingFuture
diegomarquezp Jun 6, 2024
aa601fd
increase coverage of BatcherFactory
diegomarquezp Jun 6, 2024
ffebe03
format + increase coverage in BatcherImpl
diegomarquezp Jun 6, 2024
c0957df
add javadoc for TimeConversionTestUtils
diegomarquezp Jun 6, 2024
6359ef4
increase coverage in Callables
diegomarquezp Jun 6, 2024
5167ab1
increase coverage in CheckingAttemptCallable
diegomarquezp Jun 7, 2024
dd9a1b3
add null check in ClientSettings
diegomarquezp Jun 7, 2024
1212fa7
use manual test in BatchingSettingsTest
diegomarquezp Jun 12, 2024
be18870
format
diegomarquezp Jun 12, 2024
ec6c52e
add tests with same settings builder and different test value
diegomarquezp Jun 12, 2024
d5ce8b1
chore: Add @{argLine} to prevent overwriting jacoco property
lqiu96 Jun 13, 2024
aeadeb8
restore BatchingSettingsTest
diegomarquezp Jun 13, 2024
468558b
Update gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjso…
diegomarquezp Jun 13, 2024
5384591
Merge remote-tracking branch 'origin/threeten-deprecation' into three…
diegomarquezp Jun 13, 2024
82c0679
use java.time methods in HttpJsonClientCalls
diegomarquezp Jun 13, 2024
09e9995
add tests for TimeConversionUtils
diegomarquezp Jun 26, 2024
57170d0
add license header
diegomarquezp Jun 27, 2024
1ad1ad3
Merge branch 'main' into threeten-deprecation
diegomarquezp Jun 27, 2024
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 @@ -55,7 +55,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
import org.threeten.bp.Duration;

/**
* A {@link ManagedChannel} that will send requests round-robin via a set of channels.
Expand All @@ -69,7 +68,7 @@
*/
class ChannelPool extends ManagedChannel {
@VisibleForTesting static final Logger LOG = Logger.getLogger(ChannelPool.class.getName());
private static final Duration REFRESH_PERIOD = Duration.ofMinutes(50);
private static final java.time.Duration REFRESH_PERIOD = java.time.Duration.ofMinutes(50);

private final ChannelPoolSettings settings;
private final ChannelFactory channelFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@
*/
package com.google.api.gax.grpc;

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

import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.core.ObsoleteApi;
import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.rpc.ApiCallContext;
import com.google.api.gax.rpc.ApiExceptionFactory;
Expand Down Expand Up @@ -62,7 +66,6 @@
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.threeten.bp.Duration;

/**
* GrpcCallContext encapsulates context data used to make a grpc call.
Expand All @@ -84,9 +87,9 @@ public final class GrpcCallContext implements ApiCallContext {
private final Channel channel;
@Nullable private final Credentials credentials;
private final CallOptions callOptions;
@Nullable private final Duration timeout;
@Nullable private final Duration streamWaitTimeout;
@Nullable private final Duration streamIdleTimeout;
@Nullable private final java.time.Duration timeout;
@Nullable private final java.time.Duration streamWaitTimeout;
@Nullable private final java.time.Duration streamIdleTimeout;
@Nullable private final Integer channelAffinity;
@Nullable private final RetrySettings retrySettings;
@Nullable private final ImmutableSet<StatusCode.Code> retryableCodes;
Expand Down Expand Up @@ -132,9 +135,9 @@ private GrpcCallContext(
Channel channel,
@Nullable Credentials credentials,
CallOptions callOptions,
@Nullable Duration timeout,
@Nullable Duration streamWaitTimeout,
@Nullable Duration streamIdleTimeout,
@Nullable java.time.Duration timeout,
@Nullable java.time.Duration streamWaitTimeout,
@Nullable java.time.Duration streamIdleTimeout,
@Nullable Integer channelAffinity,
ImmutableMap<String, List<String>> extraHeaders,
ApiCallContextOptions options,
Expand Down Expand Up @@ -228,8 +231,15 @@ public GrpcCallContext withEndpointContext(EndpointContext endpointContext) {
endpointContext);
}

/** This method is obsolete. Use {@link #withTimeoutDuration(java.time.Duration)} instead. */
@Override
@ObsoleteApi("Use withTimeoutDuration(java.time.Duration) instead")
public GrpcCallContext withTimeout(@Nullable org.threeten.bp.Duration timeout) {
return withTimeoutDuration(toJavaTimeDuration(timeout));
}

@Override
public GrpcCallContext withTimeout(@Nullable Duration timeout) {
public GrpcCallContext withTimeoutDuration(@Nullable java.time.Duration timeout) {
// Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts.
if (timeout != null && (timeout.isZero() || timeout.isNegative())) {
timeout = null;
Expand All @@ -255,17 +265,37 @@ public GrpcCallContext withTimeout(@Nullable Duration timeout) {
endpointContext);
}

/** This method is obsolete. Use {@link #getTimeoutDuration()} instead. */
@Nullable
@Override
public Duration getTimeout() {
@ObsoleteApi("Use getTimeoutDuration() instead")
diegomarquezp marked this conversation as resolved.
Show resolved Hide resolved
public org.threeten.bp.Duration getTimeout() {
return toThreetenDuration(getTimeoutDuration());
}

@Nullable
@Override
public java.time.Duration getTimeoutDuration() {
return timeout;
}

/**
* This method is obsolete. Use {@link #withStreamWaitTimeoutDuration(java.time.Duration)}
* instead.
*/
@Override
diegomarquezp marked this conversation as resolved.
Show resolved Hide resolved
@ObsoleteApi("Use withStreamWaitTimeoutDuration(java.time.Duration) instead")
public GrpcCallContext withStreamWaitTimeout(
@Nullable org.threeten.bp.Duration streamWaitTimeout) {
return withStreamWaitTimeoutDuration(toJavaTimeDuration(streamWaitTimeout));
}

@Override
public GrpcCallContext withStreamWaitTimeout(@Nullable Duration streamWaitTimeout) {
public GrpcCallContext withStreamWaitTimeoutDuration(
@Nullable java.time.Duration streamWaitTimeout) {
if (streamWaitTimeout != null) {
Preconditions.checkArgument(
streamWaitTimeout.compareTo(Duration.ZERO) >= 0, "Invalid timeout: < 0 s");
streamWaitTimeout.compareTo(java.time.Duration.ZERO) >= 0, "Invalid timeout: < 0 s");
}

return new GrpcCallContext(
Expand All @@ -283,11 +313,23 @@ public GrpcCallContext withStreamWaitTimeout(@Nullable Duration streamWaitTimeou
endpointContext);
}

/**
* This method is obsolete. Use {@link #withStreamIdleTimeoutDuration(java.time.Duration)}
* instead.
*/
@Override
@ObsoleteApi("Use withStreamIdleTimeoutDuration(java.time.Duration) instead")
public GrpcCallContext withStreamIdleTimeout(
@Nullable org.threeten.bp.Duration streamIdleTimeout) {
return withStreamIdleTimeoutDuration(toJavaTimeDuration(streamIdleTimeout));
}

@Override
public GrpcCallContext withStreamIdleTimeout(@Nullable Duration streamIdleTimeout) {
public GrpcCallContext withStreamIdleTimeoutDuration(
@Nullable java.time.Duration streamIdleTimeout) {
if (streamIdleTimeout != null) {
Preconditions.checkArgument(
streamIdleTimeout.compareTo(Duration.ZERO) >= 0, "Invalid timeout: < 0 s");
streamIdleTimeout.compareTo(java.time.Duration.ZERO) >= 0, "Invalid timeout: < 0 s");
}

return new GrpcCallContext(
Expand Down Expand Up @@ -424,17 +466,17 @@ public ApiCallContext merge(ApiCallContext inputCallContext) {
newTracer = callOptions.getOption(TRACER_KEY);
}

Duration newTimeout = grpcCallContext.timeout;
java.time.Duration newTimeout = grpcCallContext.timeout;
if (newTimeout == null) {
newTimeout = timeout;
}

Duration newStreamWaitTimeout = grpcCallContext.streamWaitTimeout;
java.time.Duration newStreamWaitTimeout = grpcCallContext.streamWaitTimeout;
if (newStreamWaitTimeout == null) {
newStreamWaitTimeout = streamWaitTimeout;
}

Duration newStreamIdleTimeout = grpcCallContext.streamIdleTimeout;
java.time.Duration newStreamIdleTimeout = grpcCallContext.streamIdleTimeout;
if (newStreamIdleTimeout == null) {
newStreamIdleTimeout = streamIdleTimeout;
}
Expand Down Expand Up @@ -496,25 +538,40 @@ public CallOptions getCallOptions() {
return callOptions;
}

/** This method is obsolete. Use {@link #getStreamWaitTimeoutDuration()} instead. */
@Override
@Nullable
@ObsoleteApi("Use getStreamWaitTimeoutDuration() instead")
public org.threeten.bp.Duration getStreamWaitTimeout() {
return toThreetenDuration(getStreamWaitTimeoutDuration());
}

/**
* The stream wait timeout set for this context.
*
* @see ApiCallContext#withStreamWaitTimeout(Duration)
* @see ApiCallContext#withStreamWaitTimeoutDuration(java.time.Duration)
*/
@Override
@Nullable
public Duration getStreamWaitTimeout() {
public java.time.Duration getStreamWaitTimeoutDuration() {
return streamWaitTimeout;
}

/** This method is obsolete. Use {@link #getStreamIdleTimeoutDuration()} instead. */
@Override
@Nullable
@ObsoleteApi("Use getStreamIdleTimeoutDuration() instead")
diegomarquezp marked this conversation as resolved.
Show resolved Hide resolved
public org.threeten.bp.Duration getStreamIdleTimeout() {
return toThreetenDuration(getStreamIdleTimeoutDuration());
}
/**
* The stream idle timeout set for this context.
*
* @see ApiCallContext#withStreamIdleTimeout(Duration)
* @see ApiCallContext#withStreamIdleTimeoutDuration(java.time.Duration)
*/
@Override
@Nullable
public Duration getStreamIdleTimeout() {
public java.time.Duration getStreamIdleTimeoutDuration() {
return streamIdleTimeout;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public static <RequestT, ResponseT> ClientCall<RequestT, ResponseT> newCall(
Preconditions.checkNotNull(callOptions);

// Try to convert the timeout into a deadline and use it if it occurs before the actual deadline
if (grpcContext.getTimeout() != null) {
if (grpcContext.getTimeoutDuration() != null) {
Deadline newDeadline =
Deadline.after(grpcContext.getTimeout().toMillis(), TimeUnit.MILLISECONDS);
Deadline.after(grpcContext.getTimeoutDuration().toMillis(), TimeUnit.MILLISECONDS);
Deadline oldDeadline = callOptions.getDeadline();

if (oldDeadline == null || newDeadline.isBefore(oldDeadline)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@
*/
package com.google.api.gax.grpc;

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

import com.google.api.core.ApiFunction;
import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.core.ObsoleteApi;
import com.google.api.gax.core.ExecutorProvider;
import com.google.api.gax.rpc.FixedHeaderProvider;
import com.google.api.gax.rpc.HeaderProvider;
Expand Down Expand Up @@ -67,7 +71,6 @@
import java.util.logging.Logger;
import javax.annotation.Nullable;
import javax.net.ssl.KeyManagerFactory;
import org.threeten.bp.Duration;

/**
* InstantiatingGrpcChannelProvider is a TransportChannelProvider which constructs a gRPC
Expand Down Expand Up @@ -106,8 +109,8 @@ public final class InstantiatingGrpcChannelProvider implements TransportChannelP
@Nullable private final GrpcInterceptorProvider interceptorProvider;
@Nullable private final Integer maxInboundMessageSize;
@Nullable private final Integer maxInboundMetadataSize;
@Nullable private final Duration keepAliveTime;
@Nullable private final Duration keepAliveTimeout;
@Nullable private final java.time.Duration keepAliveTime;
@Nullable private final java.time.Duration keepAliveTimeout;
@Nullable private final Boolean keepAliveWithoutCalls;
private final ChannelPoolSettings channelPoolSettings;
@Nullable private final Credentials credentials;
Expand Down Expand Up @@ -490,13 +493,25 @@ public String getEndpoint() {
return endpoint;
}

/** This method is obsolete. Use {@link #getKeepAliveTimeDuration()} instead. */
@ObsoleteApi("Use getKeepAliveTimeDuration() instead")
public org.threeten.bp.Duration getKeepAliveTime() {
return toThreetenDuration(getKeepAliveTimeDuration());
}

/** The time without read activity before sending a keepalive ping. */
public Duration getKeepAliveTime() {
public java.time.Duration getKeepAliveTimeDuration() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a breaking change. Have we released with Duration getKeepAliveTime()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@burkedavison we keep the method signature in

@ObsoleteApi("Use getKeepAliveTimeDuration() instead")
public org.threeten.bp.Duration getKeepAliveTime() {
return toThreetenDuration(getKeepAliveTimeDuration());
}

It is not a breaking change in terms of signature, but the implementation of the threeten version has changed to become a wrapper of the java.time version.

return keepAliveTime;
}

/** This method is obsolete. Use {@link #getKeepAliveTimeoutDuration()} instead */
@ObsoleteApi("Use getKeepAliveTimeoutDuration() instead")
diegomarquezp marked this conversation as resolved.
Show resolved Hide resolved
public org.threeten.bp.Duration getKeepAliveTimeout() {
return toThreetenDuration(getKeepAliveTimeoutDuration());
}

/** The time without read activity after sending a keepalive ping. */
public Duration getKeepAliveTimeout() {
public java.time.Duration getKeepAliveTimeoutDuration() {
return keepAliveTimeout;
}

Expand Down Expand Up @@ -540,8 +555,8 @@ public static final class Builder {
@Nullable private GrpcInterceptorProvider interceptorProvider;
@Nullable private Integer maxInboundMessageSize;
@Nullable private Integer maxInboundMetadataSize;
@Nullable private Duration keepAliveTime;
@Nullable private Duration keepAliveTimeout;
@Nullable private java.time.Duration keepAliveTime;
@Nullable private java.time.Duration keepAliveTimeout;
@Nullable private Boolean keepAliveWithoutCalls;
@Nullable private ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder> channelConfigurator;
@Nullable private Credentials credentials;
Expand Down Expand Up @@ -679,25 +694,53 @@ public Integer getMaxInboundMetadataSize() {
return maxInboundMetadataSize;
}

/**
* This method is obsolete. Use {@link #setKeepAliveTimeDuration(java.time.Duration)} instead.
*/
@ObsoleteApi("Use setKeepAliveTimeDuration(java.time.Duration) instead")
public Builder setKeepAliveTime(org.threeten.bp.Duration duration) {
return setKeepAliveTimeDuration(toJavaTimeDuration(duration));
}
/** The time without read activity before sending a keepalive ping. */
public Builder setKeepAliveTime(Duration duration) {
public Builder setKeepAliveTimeDuration(java.time.Duration duration) {
this.keepAliveTime = duration;
return this;
}

/** This method is obsolete. Use {@link #getKeepAliveTimeDuration()} instead. */
@ObsoleteApi("Use getKeepAliveTimeDuration() instead")
public org.threeten.bp.Duration getKeepAliveTime() {
return toThreetenDuration(getKeepAliveTimeDuration());
}

/** The time without read activity before sending a keepalive ping. */
public Duration getKeepAliveTime() {
public java.time.Duration getKeepAliveTimeDuration() {
return keepAliveTime;
}

/**
* This method is obsolete. Use {@link #setKeepAliveTimeoutDuration(java.time.Duration)}
* instead.
*/
@ObsoleteApi("Use setKeepAliveTimeoutDuration(java.time.Duration) instead")
public Builder setKeepAliveTimeout(org.threeten.bp.Duration duration) {
return setKeepAliveTimeoutDuration(toJavaTimeDuration(duration));
}

/** The time without read activity after sending a keepalive ping. */
public Builder setKeepAliveTimeout(Duration duration) {
public Builder setKeepAliveTimeoutDuration(java.time.Duration duration) {
this.keepAliveTimeout = duration;
return this;
}

/** This method is obsolete. Use {@link #getKeepAliveTimeoutDuration()} instead */
@ObsoleteApi("Use getKeepAliveTimeoutDuration() instead")
public org.threeten.bp.Duration getKeepAliveTimeout() {
return toThreetenDuration(getKeepAliveTimeoutDuration());
}

/** The time without read activity after sending a keepalive ping. */
public Duration getKeepAliveTimeout() {
public java.time.Duration getKeepAliveTimeoutDuration() {
return keepAliveTimeout;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import com.google.longrunning.WaitOperationRequest;
import com.google.protobuf.Empty;
import java.io.IOException;
import org.threeten.bp.Duration;

/** Settings class to configure an instance of {@link OperationsStub}. */
public class OperationsStubSettings extends StubSettings<OperationsStubSettings> {
Expand Down Expand Up @@ -243,13 +242,13 @@ public static class Builder extends StubSettings.Builder<OperationsStubSettings,
RetrySettings settings = null;
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
.setInitialRetryDelayDuration(java.time.Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(90000L))
.setMaxRetryDelayDuration(java.time.Duration.ofMillis(60000L))
.setInitialRpcTimeoutDuration(java.time.Duration.ofMillis(90000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(90000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.setMaxRpcTimeoutDuration(java.time.Duration.ofMillis(90000L))
.setTotalTimeoutDuration(java.time.Duration.ofMillis(600000L))
lqiu96 marked this conversation as resolved.
Show resolved Hide resolved
.build();
definitions.put("default", settings);
RETRY_PARAM_DEFINITIONS = definitions.build();
Expand Down
Loading
Loading