Skip to content

Commit 24c1566

Browse files
committed
reset java-core and showcase to main
1 parent 60a43dd commit 24c1566

File tree

8 files changed

+54
-64
lines changed

8 files changed

+54
-64
lines changed

java-core/google-cloud-core/clirr-ignored-differences.xml

-6
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,4 @@
1212
<className>com/google/cloud/ReadChannel</className>
1313
<method>long limit()</method>
1414
</difference>
15-
<difference>
16-
<differenceType>7005</differenceType>
17-
<className>com/google/cloud/testing/*</className>
18-
<method>* *(org.threeten.bp.Duration)</method>
19-
<to>*</to>
20-
</difference>
2115
</differences>

java-core/google-cloud-core/src/main/java/com/google/cloud/RetryOption.java

+7-26
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616

1717
package com.google.cloud;
1818

19-
import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration;
2019
import static com.google.common.base.Preconditions.checkNotNull;
2120

2221
import com.google.api.core.BetaApi;
23-
import com.google.api.core.ObsoleteApi;
2422
import com.google.api.gax.retrying.RetrySettings;
2523
import java.io.Serializable;
24+
import org.threeten.bp.Duration;
2625

2726
/**
2827
* This class represents an options wrapper around the {@link RetrySettings} class and is an
@@ -53,43 +52,25 @@ private RetryOption(OptionType type, Object value) {
5352
}
5453

5554
/** See {@link RetrySettings#getTotalTimeout()}. */
56-
@ObsoleteApi("Use totalTimeout(java.time.Duration) instead")
57-
public static RetryOption totalTimeout(org.threeten.bp.Duration totalTimeout) {
55+
public static RetryOption totalTimeout(Duration totalTimeout) {
5856
return new RetryOption(OptionType.TOTAL_TIMEOUT, totalTimeout);
5957
}
6058

61-
/** See {@link RetrySettings#getTotalTimeout()}. */
62-
public static RetryOption totalTimeout(java.time.Duration totalTimeout) {
63-
return totalTimeout(toThreetenDuration(totalTimeout));
64-
}
65-
6659
/** See {@link RetrySettings#getInitialRetryDelay()}. */
67-
@ObsoleteApi("Use initialRetryDelay(java.time.Duration) instead")
68-
public static RetryOption initialRetryDelay(org.threeten.bp.Duration initialRetryDelay) {
60+
public static RetryOption initialRetryDelay(Duration initialRetryDelay) {
6961
return new RetryOption(OptionType.INITIAL_RETRY_DELAY, initialRetryDelay);
7062
}
7163

72-
/** See {@link RetrySettings#getInitialRetryDelay()}. */
73-
public static RetryOption initialRetryDelay(java.time.Duration initialRetryDelay) {
74-
return initialRetryDelay(toThreetenDuration(initialRetryDelay));
75-
}
76-
7764
/** See {@link RetrySettings#getRetryDelayMultiplier()}. */
7865
public static RetryOption retryDelayMultiplier(double retryDelayMultiplier) {
7966
return new RetryOption(OptionType.RETRY_DELAY_MULTIPLIER, retryDelayMultiplier);
8067
}
8168

8269
/** See {@link RetrySettings#getMaxRetryDelay()}. */
83-
@ObsoleteApi("Use maxRetryDelay(java.time.Duration) instead")
84-
public static RetryOption maxRetryDelay(org.threeten.bp.Duration maxRetryDelay) {
70+
public static RetryOption maxRetryDelay(Duration maxRetryDelay) {
8571
return new RetryOption(OptionType.MAX_RETRY_DELAY, maxRetryDelay);
8672
}
8773

88-
/** See {@link RetrySettings#getMaxRetryDelay()}. */
89-
public static RetryOption maxRetryDelay(java.time.Duration maxRetryDelay) {
90-
return maxRetryDelay(toThreetenDuration(maxRetryDelay));
91-
}
92-
9374
/** See {@link RetrySettings#getMaxAttempts()}. */
9475
public static RetryOption maxAttempts(int maxAttempts) {
9576
return new RetryOption(OptionType.MAX_ATTEMPTS, maxAttempts);
@@ -143,16 +124,16 @@ public static RetrySettings mergeToSettings(RetrySettings settings, RetryOption.
143124
for (RetryOption option : options) {
144125
switch (option.type) {
145126
case TOTAL_TIMEOUT:
146-
builder.setTotalTimeout((org.threeten.bp.Duration) option.value);
127+
builder.setTotalTimeout((Duration) option.value);
147128
break;
148129
case INITIAL_RETRY_DELAY:
149-
builder.setInitialRetryDelay((org.threeten.bp.Duration) option.value);
130+
builder.setInitialRetryDelay((Duration) option.value);
150131
break;
151132
case RETRY_DELAY_MULTIPLIER:
152133
builder.setRetryDelayMultiplier((Double) option.value);
153134
break;
154135
case MAX_RETRY_DELAY:
155-
builder.setMaxRetryDelay((org.threeten.bp.Duration) option.value);
136+
builder.setMaxRetryDelay((Duration) option.value);
156137
break;
157138
case MAX_ATTEMPTS:
158139
builder.setMaxAttempts((Integer) option.value);

java-core/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
import java.util.Set;
7171
import java.util.regex.Matcher;
7272
import java.util.regex.Pattern;
73+
import org.threeten.bp.Duration;
7374

7475
/**
7576
* Abstract class representing service options.
@@ -786,13 +787,13 @@ public static RetrySettings getNoRetrySettings() {
786787
private static RetrySettings.Builder getDefaultRetrySettingsBuilder() {
787788
return RetrySettings.newBuilder()
788789
.setMaxAttempts(6)
789-
.setInitialRetryDelay(org.threeten.bp.Duration.ofMillis(1000L))
790-
.setMaxRetryDelay(org.threeten.bp.Duration.ofMillis(32_000L))
790+
.setInitialRetryDelay(Duration.ofMillis(1000L))
791+
.setMaxRetryDelay(Duration.ofMillis(32_000L))
791792
.setRetryDelayMultiplier(2.0)
792-
.setTotalTimeout(org.threeten.bp.Duration.ofMillis(50_000L))
793-
.setInitialRpcTimeout(org.threeten.bp.Duration.ofMillis(50_000L))
793+
.setTotalTimeout(Duration.ofMillis(50_000L))
794+
.setInitialRpcTimeout(Duration.ofMillis(50_000L))
794795
.setRpcTimeoutMultiplier(1.0)
795-
.setMaxRpcTimeout(org.threeten.bp.Duration.ofMillis(50_000L));
796+
.setMaxRpcTimeout(Duration.ofMillis(50_000L));
796797
}
797798

798799
protected abstract Set<String> getScopes();

java-core/google-cloud-core/src/main/java/com/google/cloud/testing/BaseEmulatorHelper.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import java.util.logging.Logger;
5757
import java.util.zip.ZipEntry;
5858
import java.util.zip.ZipInputStream;
59+
import org.threeten.bp.Duration;
5960

6061
/** Utility class to start and stop a local service which is used by unit testing. */
6162
@InternalApi
@@ -115,7 +116,7 @@ protected final void startProcess(String blockUntilOutput)
115116
* Waits for the local service's subprocess to terminate, and stop any possible thread listening
116117
* for its output.
117118
*/
118-
protected final int waitForProcess(java.time.Duration timeout)
119+
protected final int waitForProcess(Duration timeout)
119120
throws IOException, InterruptedException, TimeoutException {
120121
if (activeRunner != null) {
121122
int exitCode = activeRunner.waitFor(timeout);
@@ -129,7 +130,7 @@ protected final int waitForProcess(java.time.Duration timeout)
129130
return 0;
130131
}
131132

132-
private static int waitForProcess(final Process process, java.time.Duration timeout)
133+
private static int waitForProcess(final Process process, Duration timeout)
133134
throws InterruptedException, TimeoutException {
134135
if (process == null) {
135136
return 0;
@@ -180,7 +181,7 @@ public String getProjectId() {
180181
public abstract void start() throws IOException, InterruptedException;
181182

182183
/** Stops the local emulator. */
183-
public abstract void stop(java.time.Duration timeout)
184+
public abstract void stop(Duration timeout)
184185
throws IOException, InterruptedException, TimeoutException;
185186

186187
/** Resets the internal state of the emulator. */
@@ -226,7 +227,7 @@ protected interface EmulatorRunner {
226227
void start() throws IOException;
227228

228229
/** Wait for the emulator associated to this runner to terminate, returning the exit status. */
229-
int waitFor(java.time.Duration timeout) throws InterruptedException, TimeoutException;
230+
int waitFor(Duration timeout) throws InterruptedException, TimeoutException;
230231

231232
/** Returns the process associated to the emulator, if any. */
232233
Process getProcess();
@@ -264,7 +265,7 @@ public void start() throws IOException {
264265
}
265266

266267
@Override
267-
public int waitFor(java.time.Duration timeout) throws InterruptedException, TimeoutException {
268+
public int waitFor(Duration timeout) throws InterruptedException, TimeoutException {
268269
return waitForProcess(process, timeout);
269270
}
270271

@@ -374,7 +375,7 @@ public Path call() throws IOException {
374375
}
375376

376377
@Override
377-
public int waitFor(java.time.Duration timeout) throws InterruptedException, TimeoutException {
378+
public int waitFor(Duration timeout) throws InterruptedException, TimeoutException {
378379
return waitForProcess(process, timeout);
379380
}
380381

java-core/google-cloud-core/src/test/java/com/google/cloud/RetryOptionTest.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,26 @@
2121

2222
import com.google.api.gax.retrying.RetrySettings;
2323
import org.junit.Test;
24+
import org.threeten.bp.Duration;
2425

2526
public class RetryOptionTest {
2627

2728
private static final RetryOption TOTAL_TIMEOUT =
28-
RetryOption.totalTimeout(java.time.Duration.ofMillis(420L));
29+
RetryOption.totalTimeout(Duration.ofMillis(420L));
2930
private static final RetryOption INITIAL_RETRY_DELAY =
30-
RetryOption.initialRetryDelay(java.time.Duration.ofMillis(42L));
31+
RetryOption.initialRetryDelay(Duration.ofMillis(42L));
3132
private static final RetryOption RETRY_DELAY_MULTIPLIER = RetryOption.retryDelayMultiplier(1.5);
3233
private static final RetryOption MAX_RETRY_DELAY =
33-
RetryOption.maxRetryDelay(java.time.Duration.ofMillis(100));
34+
RetryOption.maxRetryDelay(Duration.ofMillis(100));
3435
private static final RetryOption MAX_ATTEMPTS = RetryOption.maxAttempts(100);
3536
private static final RetryOption JITTERED = RetryOption.jittered(false);
3637

3738
private static final RetrySettings retrySettings =
3839
RetrySettings.newBuilder()
39-
.setTotalTimeout(java.time.Duration.ofMillis(420L))
40-
.setInitialRetryDelay(java.time.Duration.ofMillis(42L))
40+
.setTotalTimeout(Duration.ofMillis(420L))
41+
.setInitialRetryDelay(Duration.ofMillis(42L))
4142
.setRetryDelayMultiplier(1.5)
42-
.setMaxRetryDelay(java.time.Duration.ofMillis(100))
43+
.setMaxRetryDelay(Duration.ofMillis(100))
4344
.setMaxAttempts(100)
4445
.setJittered(false)
4546
.build();
@@ -60,10 +61,10 @@ public void testEqualsAndHashCode() {
6061
assertNotEquals(MAX_ATTEMPTS, MAX_RETRY_DELAY);
6162
assertNotEquals(JITTERED, MAX_ATTEMPTS);
6263

63-
RetryOption totalTimeout = RetryOption.totalTimeout(java.time.Duration.ofMillis(420L));
64-
RetryOption initialRetryDelay = RetryOption.initialRetryDelay(java.time.Duration.ofMillis(42L));
64+
RetryOption totalTimeout = RetryOption.totalTimeout(Duration.ofMillis(420L));
65+
RetryOption initialRetryDelay = RetryOption.initialRetryDelay(Duration.ofMillis(42L));
6566
RetryOption retryDelayMultiplier = RetryOption.retryDelayMultiplier(1.5);
66-
RetryOption maxRetryDelay = RetryOption.maxRetryDelay(java.time.Duration.ofMillis(100));
67+
RetryOption maxRetryDelay = RetryOption.maxRetryDelay(Duration.ofMillis(100));
6768
RetryOption maxAttempts = RetryOption.maxAttempts(100);
6869
RetryOption jittered = RetryOption.jittered(false);
6970

@@ -100,17 +101,17 @@ public void testMergeToSettings() {
100101
assertEquals(retrySettings, mergedRetrySettings);
101102

102103
defRetrySettings =
103-
defRetrySettings.toBuilder().setTotalTimeout(java.time.Duration.ofMillis(420L)).build();
104+
defRetrySettings.toBuilder().setTotalTimeout(Duration.ofMillis(420L)).build();
104105
mergedRetrySettings = RetryOption.mergeToSettings(defRetrySettings, TOTAL_TIMEOUT);
105106
assertEquals(defRetrySettings, mergedRetrySettings);
106107

107108
defRetrySettings =
108-
defRetrySettings.toBuilder().setMaxRetryDelay(java.time.Duration.ofMillis(100)).build();
109+
defRetrySettings.toBuilder().setMaxRetryDelay(Duration.ofMillis(100)).build();
109110
mergedRetrySettings = RetryOption.mergeToSettings(defRetrySettings, MAX_RETRY_DELAY);
110111
assertEquals(defRetrySettings, mergedRetrySettings);
111112

112113
defRetrySettings =
113-
defRetrySettings.toBuilder().setInitialRetryDelay(java.time.Duration.ofMillis(42L)).build();
114+
defRetrySettings.toBuilder().setInitialRetryDelay(Duration.ofMillis(42L)).build();
114115
mergedRetrySettings = RetryOption.mergeToSettings(defRetrySettings, INITIAL_RETRY_DELAY);
115116
assertEquals(defRetrySettings, mergedRetrySettings);
116117

java-core/google-cloud-core/src/test/java/com/google/cloud/SerializationTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.common.collect.ImmutableList;
2424
import com.google.common.collect.ImmutableMap;
2525
import java.io.Serializable;
26+
import org.threeten.bp.Duration;
2627

2728
public class SerializationTest extends BaseSerializationTest {
2829

@@ -36,7 +37,7 @@ public class SerializationTest extends BaseSerializationTest {
3637
private static final Role SOME_ROLE = Role.viewer();
3738
private static final Policy SOME_IAM_POLICY = Policy.newBuilder().build();
3839
private static final RetryOption CHECKING_PERIOD =
39-
RetryOption.initialRetryDelay(java.time.Duration.ofSeconds(42));
40+
RetryOption.initialRetryDelay(Duration.ofSeconds(42));
4041
private static final LabelDescriptor LABEL_DESCRIPTOR =
4142
new LabelDescriptor("project_id", ValueType.STRING, "The project id");
4243
private static final MonitoredResourceDescriptor MONITORED_RESOURCE_DESCRIPTOR =

java-core/google-cloud-core/src/test/java/com/google/cloud/testing/BaseEmulatorHelperTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.logging.Logger;
3434
import org.easymock.EasyMock;
3535
import org.junit.Test;
36+
import org.threeten.bp.Duration;
3637

3738
public class BaseEmulatorHelperTest {
3839

@@ -70,8 +71,7 @@ public void start() throws IOException, InterruptedException {
7071
}
7172

7273
@Override
73-
public void stop(java.time.Duration timeout)
74-
throws IOException, InterruptedException, TimeoutException {
74+
public void stop(Duration timeout) throws IOException, InterruptedException, TimeoutException {
7575
waitForProcess(timeout);
7676
}
7777

@@ -91,13 +91,13 @@ public void testEmulatorHelper() throws IOException, InterruptedException, Timeo
9191
emulatorRunner.start();
9292
EasyMock.expectLastCall();
9393
EasyMock.expect(emulatorRunner.getProcess()).andReturn(process);
94-
emulatorRunner.waitFor(java.time.Duration.ofMinutes(1));
94+
emulatorRunner.waitFor(Duration.ofMinutes(1));
9595
EasyMock.expectLastCall().andReturn(0);
9696
EasyMock.replay(process, emulatorRunner);
9797
TestEmulatorHelper helper =
9898
new TestEmulatorHelper(ImmutableList.of(emulatorRunner), BLOCK_UNTIL);
9999
helper.start();
100-
helper.stop(java.time.Duration.ofMinutes(1));
100+
helper.stop(Duration.ofMinutes(1));
101101
EasyMock.verify();
102102
}
103103

@@ -157,13 +157,13 @@ public void testEmulatorHelperMultipleRunners()
157157
secondRunner.start();
158158
EasyMock.expectLastCall();
159159
EasyMock.expect(secondRunner.getProcess()).andReturn(process);
160-
secondRunner.waitFor(java.time.Duration.ofMinutes(1));
160+
secondRunner.waitFor(Duration.ofMinutes(1));
161161
EasyMock.expectLastCall().andReturn(0);
162162
EasyMock.replay(process, secondRunner);
163163
TestEmulatorHelper helper =
164164
new TestEmulatorHelper(ImmutableList.of(firstRunner, secondRunner), BLOCK_UNTIL);
165165
helper.start();
166-
helper.stop(java.time.Duration.ofMinutes(1));
166+
helper.stop(Duration.ofMinutes(1));
167167
EasyMock.verify();
168168
}
169169

showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITDynamicRoutingHeaders.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import io.grpc.MethodDescriptor;
4444
import java.util.Arrays;
4545
import java.util.List;
46+
import java.util.concurrent.TimeUnit;
4647
import java.util.stream.Collectors;
4748
import org.junit.After;
4849
import org.junit.Before;
@@ -153,11 +154,21 @@ public void createClients() throws Exception {
153154
}
154155

155156
@After
156-
public void destroyClient() {
157+
public void destroyClient() throws InterruptedException {
157158
grpcClient.close();
158-
httpJsonClient.close();
159159
grpcComplianceClient.close();
160+
161+
httpJsonClient.close();
160162
httpJsonComplianceClient.close();
163+
164+
grpcClient.awaitTermination(TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS);
165+
grpcComplianceClient.awaitTermination(
166+
TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS);
167+
168+
httpJsonClient.awaitTermination(
169+
TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS);
170+
httpJsonComplianceClient.awaitTermination(
171+
TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS);
161172
}
162173

163174
@Test

0 commit comments

Comments
 (0)