Skip to content

Commit 8a532c5

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 6733 b: refs/heads/tswast-patch-1 c: 2d1e836 h: refs/heads/master i: 6731: 92559fc
1 parent b7b911e commit 8a532c5

16 files changed

Lines changed: 26 additions & 75 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: b5dd44a1e66670cf385a337dbf09a883d942fc2a
60+
refs/heads/tswast-patch-1: 2d1e83693589a1b0658a50d044c8928430df90f0
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/CONTRIBUTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ End-to-end tests should ensure that gcloud-java works when running on the
3030

3131
When changes are made to authentication and project ID-related code, authentication and project ID inference should be tested using all relevant methods detailed in the [authentication docs](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) and [project ID docs](https://github.com/GoogleCloudPlatform/gcloud-java#specifying-a-project-id).
3232

33-
Known issue: If you have installed the Google Cloud SDK, be sure to log in (using `gcloud auth login`) before running tests. Though the Datastore tests use a local Datastore emulator that doesn't require authentication, they will not run if you have the Google Cloud SDK installed but aren't authenticated.
34-
3533
Adding Features
3634
---------------
3735
In order to add a feature to gcloud-java:

branches/tswast-patch-1/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ public void setUp() {
262262
options = BigQueryOptions.builder()
263263
.projectId(PROJECT)
264264
.serviceRpcFactory(rpcFactoryMock)
265+
.retryParams(RetryParams.noRetries())
265266
.build();
266267
}
267268

branches/tswast-patch-1/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ public B authCredentials(AuthCredentials authCredentials) {
264264

265265
/**
266266
* Sets configuration parameters for request retries. If no configuration is set
267-
* {@link RetryParams#noRetries()} is used.
267+
* {@link RetryParams#defaultInstance()} is used. To disable retries, supply
268+
* {@link RetryParams#noRetries()} here.
268269
*
269270
* @return the builder
270271
*/
@@ -325,7 +326,7 @@ protected ServiceOptions(Class<? extends ServiceFactory<ServiceT, OptionsT>> ser
325326
authCredentials =
326327
builder.authCredentials != null ? builder.authCredentials : defaultAuthCredentials();
327328
authCredentialsState = authCredentials != null ? authCredentials.capture() : null;
328-
retryParams = builder.retryParams;
329+
retryParams = firstNonNull(builder.retryParams, RetryParams.defaultInstance());
329330
serviceFactory = firstNonNull(builder.serviceFactory,
330331
getFromServiceLoader(serviceFactoryClass, defaultServiceFactory()));
331332
serviceFactoryClassName = serviceFactory.getClass().getName();

branches/tswast-patch-1/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DatastoreRpc.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ public int httpStatus() {
7979
private final int httpStatus;
8080
private final boolean retryable;
8181

82-
public DatastoreRpcException(Reason reason, Throwable cause) {
83-
this(reason.name(), reason.httpStatus, reason.retryable, reason.description, cause);
82+
public DatastoreRpcException(Reason reason) {
83+
this(reason.name(), reason.httpStatus, reason.retryable, reason.description);
8484
}
8585

86-
public DatastoreRpcException(String reason, int httpStatus, boolean retryable, String message, Throwable cause) {
87-
super(message, cause);
86+
public DatastoreRpcException(String reason, int httpStatus, boolean retryable, String message) {
87+
super(message);
8888
this.reason = reason;
8989
this.httpStatus = httpStatus;
9090
this.retryable = retryable;

branches/tswast-patch-1/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DefaultDatastoreRpc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ private static DatastoreRpcException translate(DatastoreException exception) {
124124
reason = HTTP_STATUS_TO_REASON.get(exception.getCode());
125125
}
126126
if (reason != null) {
127-
return new DatastoreRpcException(reason, exception);
127+
return new DatastoreRpcException(reason);
128128
} else {
129129
boolean retryable = false;
130130
reasonStr = "Unknown";
131131
if (exception.getCause() instanceof SocketTimeoutException) {
132132
retryable = true;
133133
reasonStr = "Request timeout";
134134
}
135-
return new DatastoreRpcException(reasonStr, exception.getCode(), retryable, message, exception);
135+
return new DatastoreRpcException(reasonStr, exception.getCode(), retryable, message);
136136
}
137137
}
138138

branches/tswast-patch-1/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreExceptionTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,12 @@ public void testDatastoreError() throws Exception {
4242

4343
@Test
4444
public void testTranslateAndThrow() throws Exception {
45-
DatastoreRpcException toTranslate = null; // should be preserved as a cause
4645
for (Reason reason : Reason.values()) {
4746
try {
48-
toTranslate = new DatastoreRpcException(reason, null);
49-
DatastoreException.translateAndThrow(toTranslate);
47+
DatastoreException.translateAndThrow(new DatastoreRpcException(reason));
5048
fail("Exception expected");
5149
} catch (DatastoreException ex) {
5250
assertEquals(reason.name(), ex.datastoreError().name());
53-
assertEquals(toTranslate, ex.getCause());
5451
}
5552
}
5653
}

branches/tswast-patch-1/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public void setUp() {
125125
options = DatastoreOptions.builder()
126126
.projectId(PROJECT_ID)
127127
.host("http://localhost:" + PORT)
128+
.retryParams(RetryParams.noRetries())
128129
.build();
129130
datastore = options.service();
130131
StructuredQuery<Key> query = Query.keyQueryBuilder().build();
@@ -734,7 +735,7 @@ public void testRetryableException() throws Exception {
734735
EasyMock.expect(rpcFactoryMock.create(EasyMock.anyObject(DatastoreOptions.class)))
735736
.andReturn(rpcMock);
736737
EasyMock.expect(rpcMock.lookup(requestPb))
737-
.andThrow(new DatastoreRpc.DatastoreRpcException(Reason.UNAVAILABLE, null))
738+
.andThrow(new DatastoreRpc.DatastoreRpcException(Reason.UNAVAILABLE))
738739
.andReturn(responsePb);
739740
EasyMock.replay(rpcFactoryMock, rpcMock);
740741
DatastoreOptions options = this.options.toBuilder()
@@ -756,7 +757,7 @@ public void testNonRetryableException() throws Exception {
756757
EasyMock.expect(rpcFactoryMock.create(EasyMock.anyObject(DatastoreOptions.class)))
757758
.andReturn(rpcMock);
758759
EasyMock.expect(rpcMock.lookup(requestPb))
759-
.andThrow(new DatastoreRpc.DatastoreRpcException(Reason.PERMISSION_DENIED, null))
760+
.andThrow(new DatastoreRpc.DatastoreRpcException(Reason.PERMISSION_DENIED))
760761
.times(1);
761762
EasyMock.replay(rpcFactoryMock, rpcMock);
762763
RetryParams retryParams = RetryParams.builder().retryMinAttempts(2).build();

branches/tswast-patch-1/gcloud-java-examples/src/main/java/com/google/gcloud/examples/StorageExample.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import com.google.gcloud.AuthCredentials;
2020
import com.google.gcloud.AuthCredentials.ServiceAccountAuthCredentials;
21-
import com.google.gcloud.RetryParams;
2221
import com.google.gcloud.spi.StorageRpc.Tuple;
2322
import com.google.gcloud.storage.Blob;
2423
import com.google.gcloud.storage.BlobId;
@@ -549,8 +548,7 @@ public static void main(String... args) throws Exception {
549548
printUsage();
550549
return;
551550
}
552-
StorageOptions.Builder optionsBuilder =
553-
StorageOptions.builder().retryParams(RetryParams.defaultInstance());
551+
StorageOptions.Builder optionsBuilder = StorageOptions.builder();
554552
StorageAction action;
555553
String actionName;
556554
if (args.length >= 2 && !ACTIONS.containsKey(args[0])) {

branches/tswast-patch-1/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import com.google.common.collect.ImmutableMap;
2727
import com.google.gcloud.Page;
28-
import com.google.gcloud.RetryParams;
2928
import com.google.gcloud.resourcemanager.ProjectInfo.ResourceId;
3029
import com.google.gcloud.resourcemanager.ResourceManager.ProjectField;
3130
import com.google.gcloud.resourcemanager.ResourceManager.ProjectGetOption;
@@ -271,7 +270,6 @@ public void testRetryableException() {
271270
EasyMock.replay(rpcFactoryMock);
272271
ResourceManager resourceManagerMock = ResourceManagerOptions.builder()
273272
.serviceRpcFactory(rpcFactoryMock)
274-
.retryParams(RetryParams.defaultInstance())
275273
.build()
276274
.service();
277275
EasyMock.expect(resourceManagerRpcMock.get(PARTIAL_PROJECT.projectId(), EMPTY_RPC_OPTIONS))
@@ -291,7 +289,6 @@ public void testNonRetryableException() {
291289
EasyMock.replay(rpcFactoryMock);
292290
ResourceManager resourceManagerMock = ResourceManagerOptions.builder()
293291
.serviceRpcFactory(rpcFactoryMock)
294-
.retryParams(RetryParams.defaultInstance())
295292
.build()
296293
.service();
297294
EasyMock.expect(resourceManagerRpcMock.get(PARTIAL_PROJECT.projectId(), EMPTY_RPC_OPTIONS))

0 commit comments

Comments
 (0)