Skip to content

Commit 60a43dd

Browse files
committed
reformat
1 parent 2a4949b commit 60a43dd

21 files changed

+86
-49
lines changed

gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/SettingsTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,9 @@ public void testWatchDogCheckInterval_backportMethodsBehaveCorrectly() {
378378
};
379379
testDurationMethod(
380380
123l,
381-
jt -> build.apply(() -> FakeStubSettings.newBuilder().setStreamWatchdogCheckIntervalDuration(jt)),
381+
jt ->
382+
build.apply(
383+
() -> FakeStubSettings.newBuilder().setStreamWatchdogCheckIntervalDuration(jt)),
382384
tt -> build.apply(() -> FakeStubSettings.newBuilder().setStreamWatchdogCheckInterval(tt)),
383385
ss -> ss.getStreamWatchdogCheckIntervalDuration(),
384386
ss -> ss.getStreamWatchdogCheckInterval());

gax-java/gax/src/main/java/com/google/api/gax/retrying/BasicRetryingFuture.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ void handleAttempt(Throwable throwable, ResponseT response) {
187187
"retriableException: " + throwable
188188
});
189189
}
190-
tracer.attemptFailedDuration(throwable, nextAttemptSettings.getRandomizedRetryDelayDuration());
190+
tracer.attemptFailedDuration(
191+
throwable, nextAttemptSettings.getRandomizedRetryDelayDuration());
191192
attemptSettings = nextAttemptSettings;
192193
setAttemptResult(throwable, response, true);
193194
// a new attempt will be (must be) scheduled by an external executor

gax-java/gax/src/main/java/com/google/api/gax/retrying/TimedAttemptSettings.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ public abstract static class Builder {
107107
public abstract Builder setGlobalSettings(RetrySettings value);
108108

109109
/**
110-
* Backport of {@link #setRetryDelayDuration(java.time.Duration)} using {@link org.threeten.bp.Duration}
110+
* Backport of {@link #setRetryDelayDuration(java.time.Duration)} using {@link
111+
* org.threeten.bp.Duration}
111112
*/
112113
@ObsoleteApi("Use setRetryDelayDuration(java.time.Duration) instead")
113114
public abstract Builder setRetryDelay(org.threeten.bp.Duration value);
@@ -121,7 +122,8 @@ public final Builder setRetryDelayDuration(java.time.Duration value) {
121122
}
122123

123124
/**
124-
* Backport of {@link #setRpcTimeoutDuration(java.time.Duration)} using {@link org.threeten.bp.Duration}
125+
* Backport of {@link #setRpcTimeoutDuration(java.time.Duration)} using {@link
126+
* org.threeten.bp.Duration}
125127
*/
126128
@ObsoleteApi("Use setRpcTimeoutDuration(java.time.Duration) instead")
127129
public abstract Builder setRpcTimeout(org.threeten.bp.Duration value);

gax-java/gax/src/main/java/com/google/api/gax/rpc/Callables.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ private static <ResponseT> ScheduledRetryingExecutor<ResponseT> getRetryingExecu
105105
settings =
106106
settings
107107
.toBuilder()
108-
.setSimpleTimeoutNoRetriesDuration(settings.getRetrySettings().getTotalTimeoutDuration())
108+
.setSimpleTimeoutNoRetriesDuration(
109+
settings.getRetrySettings().getTotalTimeoutDuration())
109110
.build();
110111
}
111112

@@ -129,7 +130,8 @@ public static <RequestT, ResponseT> ServerStreamingCallable<RequestT, ResponseT>
129130
settings =
130131
settings
131132
.toBuilder()
132-
.setSimpleTimeoutNoRetriesDuration(settings.getRetrySettings().getTotalTimeoutDuration())
133+
.setSimpleTimeoutNoRetriesDuration(
134+
settings.getRetrySettings().getTotalTimeoutDuration())
133135
.build();
134136
}
135137

gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ public static ClientContext create(StubSettings settings) throws IOException {
252252
if (watchdogProvider != null) {
253253
if (watchdogProvider.needsCheckInterval()) {
254254
watchdogProvider =
255-
watchdogProvider.withCheckIntervalDuration(settings.getStreamWatchdogCheckIntervalDuration());
255+
watchdogProvider.withCheckIntervalDuration(
256+
settings.getStreamWatchdogCheckIntervalDuration());
256257
}
257258
if (watchdogProvider.needsClock()) {
258259
watchdogProvider = watchdogProvider.withClock(clock);

gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientSettings.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
*/
3030
package com.google.api.gax.rpc;
3131

32+
import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration;
33+
3234
import com.google.api.core.ApiClock;
3335
import com.google.api.core.ApiFunction;
3436
import com.google.api.core.ObsoleteApi;
@@ -40,8 +42,6 @@
4042
import javax.annotation.Nonnull;
4143
import javax.annotation.Nullable;
4244

43-
import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration;
44-
4545
/**
4646
* A base settings class to configure a client class.
4747
*

gax-java/gax/src/main/java/com/google/api/gax/rpc/FixedWatchdogProvider.java

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import com.google.api.core.ApiClock;
3333
import com.google.api.core.InternalApi;
3434
import com.google.api.core.ObsoleteApi;
35-
3635
import java.util.concurrent.ScheduledExecutorService;
3736
import javax.annotation.Nonnull;
3837
import javax.annotation.Nullable;

gax-java/gax/src/main/java/com/google/api/gax/rpc/InstantiatingWatchdogProvider.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
*/
3030
package com.google.api.gax.rpc;
3131

32+
import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration;
33+
3234
import com.google.api.core.ApiClock;
3335
import com.google.api.core.InternalApi;
3436
import com.google.api.core.ObsoleteApi;
@@ -37,8 +39,6 @@
3739
import javax.annotation.Nonnull;
3840
import javax.annotation.Nullable;
3941

40-
import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration;
41-
4242
/**
4343
* A watchdog provider which instantiates a new provider on every request.
4444
*
@@ -90,7 +90,7 @@ public WatchdogProvider withCheckInterval(@Nonnull org.threeten.bp.Duration chec
9090
@Override
9191
public WatchdogProvider withCheckIntervalDuration(@Nonnull java.time.Duration checkInterval) {
9292
return new InstantiatingWatchdogProvider(
93-
clock, executor, Preconditions.checkNotNull(checkInterval));
93+
clock, executor, Preconditions.checkNotNull(checkInterval));
9494
}
9595

9696
@Override

gax-java/gax/src/main/java/com/google/api/gax/rpc/ServerStreamingCallSettings.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ public java.time.Duration getIdleTimeoutDuration() {
317317
}
318318

319319
/**
320-
* Overlad of {@link #setIdleTimeoutDuration(java.time.Duration)} using {@link org.threeten.bp.Duration}
320+
* Overlad of {@link #setIdleTimeoutDuration(java.time.Duration)} using {@link
321+
* org.threeten.bp.Duration}
321322
*/
322323
@ObsoleteApi("Use setIdleTimeoutDuration(java.time.Duration) instead")
323324
public Builder<RequestT, ResponseT> setIdleTimeout(
@@ -329,7 +330,8 @@ public Builder<RequestT, ResponseT> setIdleTimeout(
329330
* Set how long to wait before considering the stream orphaned by the user and closing it.
330331
* {@link java.time.Duration#ZERO} disables the check for abandoned streams.
331332
*/
332-
public Builder<RequestT, ResponseT> setIdleTimeoutDuration(@Nonnull java.time.Duration idleTimeout) {
333+
public Builder<RequestT, ResponseT> setIdleTimeoutDuration(
334+
@Nonnull java.time.Duration idleTimeout) {
333335
this.idleTimeout = Preconditions.checkNotNull(idleTimeout);
334336
return this;
335337
}
@@ -360,7 +362,8 @@ public Builder<RequestT, ResponseT> setWaitTimeout(
360362
* Set the maximum amount of time to wait for the next message from the server. {@link
361363
* java.time.Duration#ZERO} disables the check for abandoned streams.
362364
*/
363-
public Builder<RequestT, ResponseT> setWaitTimeoutDuration(@Nonnull java.time.Duration waitTimeout) {
365+
public Builder<RequestT, ResponseT> setWaitTimeoutDuration(
366+
@Nonnull java.time.Duration waitTimeout) {
364367
this.waitTimeout = waitTimeout;
365368
return this;
366369
}

gax-java/gax/src/main/java/com/google/api/gax/rpc/WatchdogProvider.java

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import com.google.api.core.ApiClock;
3333
import com.google.api.core.InternalApi;
3434
import com.google.api.core.ObsoleteApi;
35-
3635
import java.util.concurrent.ScheduledExecutorService;
3736
import javax.annotation.Nonnull;
3837

gax-java/gax/src/test/java/com/google/api/gax/batching/BatcherImplTest.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,10 @@ public void testWhenThresholdIsDisabled() throws Exception {
386386
@Test
387387
public void testWhenDelayThresholdExceeds() throws Exception {
388388
BatchingSettings settings =
389-
batchingSettings.toBuilder().setDelayThresholdDuration(java.time.Duration.ofMillis(100)).build();
389+
batchingSettings
390+
.toBuilder()
391+
.setDelayThresholdDuration(java.time.Duration.ofMillis(100))
392+
.build();
390393
underTest = createDefaultBatcherImpl(settings, null);
391394
Future<Integer> result = underTest.add(6);
392395
assertThat(result.isDone()).isFalse();
@@ -417,7 +420,10 @@ public ApiFuture<List<Integer>> futureCall(
417420
}
418421
};
419422
BatchingSettings settings =
420-
batchingSettings.toBuilder().setDelayThresholdDuration(java.time.Duration.ofMillis(50)).build();
423+
batchingSettings
424+
.toBuilder()
425+
.setDelayThresholdDuration(java.time.Duration.ofMillis(50))
426+
.build();
421427

422428
try (final BatcherImpl<Integer, Integer, LabeledIntList, List<Integer>> batcherTest =
423429
new BatcherImpl<>(SQUARER_BATCHING_DESC_V2, callable, labeledIntList, settings, EXECUTOR)) {

gax-java/gax/src/test/java/com/google/api/gax/batching/ThresholdBatcherTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ public void testBatchingWithDelay() throws Exception {
196196
AccumulatingBatchReceiver<SimpleBatch> receiver =
197197
new AccumulatingBatchReceiver<>(ApiFutures.<Void>immediateFuture(null));
198198
ThresholdBatcher<SimpleBatch> batcher =
199-
createSimpleBatcherBuidler(receiver).setMaxDelayDuration(java.time.Duration.ofMillis(100)).build();
199+
createSimpleBatcherBuidler(receiver)
200+
.setMaxDelayDuration(java.time.Duration.ofMillis(100))
201+
.build();
200202

201203
batcher.add(SimpleBatch.fromInteger(3));
202204
batcher.add(SimpleBatch.fromInteger(5));

gax-java/gax/src/test/java/com/google/api/gax/retrying/AbstractRetryingExecutorTest.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ public void testSuccessWithFailures() throws Exception {
143143
assertEquals(5, future.getAttemptSettings().getAttemptCount());
144144

145145
verify(tracer, times(6)).attemptStarted(eq("request"), anyInt());
146-
verify(tracer, times(5)).attemptFailedDuration(any(Throwable.class), any(java.time.Duration.class));
146+
verify(tracer, times(5))
147+
.attemptFailedDuration(any(Throwable.class), any(java.time.Duration.class));
147148
verify(tracer, times(1)).attemptSucceeded();
148149
verifyNoMoreInteractions(tracer);
149150
}
@@ -188,7 +189,8 @@ public void testMaxRetriesExceeded() throws Exception {
188189
assertEquals(5, future.getAttemptSettings().getAttemptCount());
189190

190191
verify(tracer, times(6)).attemptStarted(eq("request"), anyInt());
191-
verify(tracer, times(5)).attemptFailedDuration(any(Throwable.class), any(java.time.Duration.class));
192+
verify(tracer, times(5))
193+
.attemptFailedDuration(any(Throwable.class), any(java.time.Duration.class));
192194
verify(tracer, times(1)).attemptFailedRetriesExhausted(any(Throwable.class));
193195
verifyNoMoreInteractions(tracer);
194196
}
@@ -266,7 +268,8 @@ public void testCancelByRetryingAlgorithm() throws Exception {
266268

267269
verify(tracer, times(5)).attemptStarted(eq("request"), anyInt());
268270
// Pre-apocalypse failures
269-
verify(tracer, times(4)).attemptFailedDuration(any(Throwable.class), any(java.time.Duration.class));
271+
verify(tracer, times(4))
272+
.attemptFailedDuration(any(Throwable.class), any(java.time.Duration.class));
270273
// Apocalypse failure
271274
verify(tracer, times(1)).attemptFailedRetriesExhausted(any(CancellationException.class));
272275
verifyNoMoreInteractions(tracer);
@@ -286,7 +289,8 @@ public void testUnexpectedExceptionFromRetryAlgorithm() throws Exception {
286289

287290
verify(tracer, times(5)).attemptStarted(eq("request"), anyInt());
288291
// Pre-apocalypse failures
289-
verify(tracer, times(4)).attemptFailedDuration(any(Throwable.class), any(java.time.Duration.class));
292+
verify(tracer, times(4))
293+
.attemptFailedDuration(any(Throwable.class), any(java.time.Duration.class));
290294
// Apocalypse failure
291295
verify(tracer, times(1)).attemptPermanentFailure(any(RuntimeException.class));
292296
verifyNoMoreInteractions(tracer);

gax-java/gax/src/test/java/com/google/api/gax/rpc/AttemptCallableTest.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ public void testRpcTimeout() {
8888

8989
// Make sure that the rpc timeout is set
9090
java.time.Duration timeout = java.time.Duration.ofSeconds(10);
91-
currentAttemptSettings = currentAttemptSettings.toBuilder().setRpcTimeoutDuration(timeout).build();
91+
currentAttemptSettings =
92+
currentAttemptSettings.toBuilder().setRpcTimeoutDuration(timeout).build();
9293

9394
callable.call();
9495

@@ -109,7 +110,8 @@ public void testRpcTimeoutIsNotErased() {
109110
FakeCallContext.createDefault().withTimeoutDuration(callerTimeout);
110111

111112
java.time.Duration timeout = java.time.Duration.ofMillis(5);
112-
currentAttemptSettings = currentAttemptSettings.toBuilder().setRpcTimeoutDuration(timeout).build();
113+
currentAttemptSettings =
114+
currentAttemptSettings.toBuilder().setRpcTimeoutDuration(timeout).build();
113115

114116
AttemptCallable<String, String> callable =
115117
new AttemptCallable<>(mockInnerCallable, "fake-request", callerCallContext);

gax-java/gax/src/test/java/com/google/api/gax/rpc/CallableTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ public void testNonRetriedCallable() throws Exception {
8686
RequestMutator requestMutator = (request -> modifiedRequest);
8787

8888
UnaryCallSettings<Object, Object> callSettings =
89-
UnaryCallSettings.newUnaryCallSettingsBuilder().setSimpleTimeoutNoRetriesDuration(timeout).build();
89+
UnaryCallSettings.newUnaryCallSettingsBuilder()
90+
.setSimpleTimeoutNoRetriesDuration(timeout)
91+
.build();
9092
UnaryCallable<String, String> callable =
9193
Callables.retrying(innerCallable, callSettings, clientContext, requestMutator);
9294
String expectedResponse = "No, my refrigerator is not running!";

gax-java/gax/src/test/java/com/google/api/gax/rpc/CheckingAttemptCallableTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ public void testRpcTimeout() {
8888

8989
// Make sure that the rpc timeout is set
9090
java.time.Duration timeout = java.time.Duration.ofSeconds(10);
91-
currentAttemptSettings = currentAttemptSettings.toBuilder().setRpcTimeoutDuration(timeout).build();
91+
currentAttemptSettings =
92+
currentAttemptSettings.toBuilder().setRpcTimeoutDuration(timeout).build();
9293

9394
callable.call();
9495

gax-java/gax/src/test/java/com/google/api/gax/rpc/FixedWatchdogProviderTest.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
*/
3030
package com.google.api.gax.rpc;
3131

32-
import static com.google.api.gax.util.TimeConversionTestUtils.testDurationMethod;
3332
import static com.google.common.truth.Truth.assertThat;
3433
import static org.junit.Assert.assertThrows;
3534

@@ -101,9 +100,15 @@ public void testNoModifications() {
101100

102101
@Test
103102
public void testWithCheckInterval_backportMethodsBehaveTheSame() {
104-
assertThrows(UnsupportedOperationException.class, () -> FixedWatchdogProvider.create(null)
105-
.withCheckIntervalDuration(java.time.Duration.ofMillis(123l)));
106-
assertThrows(UnsupportedOperationException.class, () -> FixedWatchdogProvider.create(null)
107-
.withCheckInterval(org.threeten.bp.Duration.ofMillis(123l)));
103+
assertThrows(
104+
UnsupportedOperationException.class,
105+
() ->
106+
FixedWatchdogProvider.create(null)
107+
.withCheckIntervalDuration(java.time.Duration.ofMillis(123l)));
108+
assertThrows(
109+
UnsupportedOperationException.class,
110+
() ->
111+
FixedWatchdogProvider.create(null)
112+
.withCheckInterval(org.threeten.bp.Duration.ofMillis(123l)));
108113
}
109114
}

gax-java/gax/src/test/java/com/google/api/gax/rpc/InstantiatingWatchdogProviderTest.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public void happyPath() {
7171
@Test
7272
public void requiresExecutor() {
7373
WatchdogProvider provider =
74-
InstantiatingWatchdogProvider.create().withCheckIntervalDuration(checkInterval).withClock(clock);
74+
InstantiatingWatchdogProvider.create()
75+
.withCheckIntervalDuration(checkInterval)
76+
.withClock(clock);
7577

7678
Throwable actualError = null;
7779
try {
@@ -114,15 +116,14 @@ public void requiresClock() {
114116

115117
@Test
116118
public void testCheckInterval_backportMethodsBehaveCorrectly() {
117-
final InstantiatingWatchdogProvider baseProvider = (InstantiatingWatchdogProvider) InstantiatingWatchdogProvider.create()
118-
.withClock(clock)
119-
.withExecutor(executor);
119+
final InstantiatingWatchdogProvider baseProvider =
120+
(InstantiatingWatchdogProvider)
121+
InstantiatingWatchdogProvider.create().withClock(clock).withExecutor(executor);
120122
testDurationMethod(
121-
123l,
122-
jt -> baseProvider.withCheckIntervalDuration(jt),
123-
tt -> baseProvider.withCheckInterval(tt),
124-
wp -> wp.getWatchdog().getScheduleIntervalDuration(),
125-
wp -> wp.getWatchdog().getScheduleInterval()
126-
);
123+
123l,
124+
jt -> baseProvider.withCheckIntervalDuration(jt),
125+
tt -> baseProvider.withCheckInterval(tt),
126+
wp -> wp.getWatchdog().getScheduleIntervalDuration(),
127+
wp -> wp.getWatchdog().getScheduleInterval());
127128
}
128129
}

gax-java/gax/src/test/java/com/google/api/gax/rpc/ServerStreamingAttemptCallableTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ private static class FakeRetryingFuture extends AbstractApiFuture<Void>
474474
this.attemptCallable = attemptCallable;
475475
attemptSettings =
476476
TimedAttemptSettings.newBuilder()
477-
.setGlobalSettings(RetrySettings.newBuilder().setTotalTimeoutDuration(totalTimeout).build())
477+
.setGlobalSettings(
478+
RetrySettings.newBuilder().setTotalTimeoutDuration(totalTimeout).build())
478479
.setFirstAttemptStartTimeNanos(0)
479480
.setAttemptCount(0)
480481
.setOverallAttemptCount(0)

gax-java/gax/src/test/java/com/google/api/gax/rpc/UnaryCallSettingsTest.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ public void testToString() {
153153
public void testWatchDogCheckInterval_backportMethodsBehaveCorrectly() {
154154
testDurationMethod(
155155
123l,
156-
jt -> UnaryCallSettings.newUnaryCallSettingsBuilder().setSimpleTimeoutNoRetriesDuration(jt).build(),
156+
jt ->
157+
UnaryCallSettings.newUnaryCallSettingsBuilder()
158+
.setSimpleTimeoutNoRetriesDuration(jt)
159+
.build(),
157160
tt -> UnaryCallSettings.newUnaryCallSettingsBuilder().setSimpleTimeoutNoRetries(tt).build(),
158161
ucs -> ucs.getRetrySettings().getTotalTimeoutDuration(),
159162
ucs -> ucs.getRetrySettings().getTotalTimeout());

gax-java/gax/src/test/java/com/google/api/gax/tracing/MetricsTestUtils.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@
3636
public class MetricsTestUtils {
3737
public static void reportFailedAttempt(ApiTracer tracer, Exception ex, Object delayValue) {
3838
try {
39-
final String methodName = delayValue.getClass().getName().startsWith("java.time") ? "attemptFailedDuration" : "attemptFailed";
39+
final String methodName =
40+
delayValue.getClass().getName().startsWith("java.time")
41+
? "attemptFailedDuration"
42+
: "attemptFailed";
4043
Method attemptFailed =
41-
tracer
42-
.getClass()
43-
.getDeclaredMethod(methodName, Throwable.class, delayValue.getClass());
44+
tracer.getClass().getDeclaredMethod(methodName, Throwable.class, delayValue.getClass());
4445
attemptFailed.invoke(tracer, ex, delayValue);
4546
} catch (Exception e) {
4647
fail();

0 commit comments

Comments
 (0)