Skip to content

Commit d9590ea

Browse files
author
Ajay Kannan
committed
Fix ServiceOptions merge bug, remove unnecessary protected modifier from DateTime, set cursorAfter to endCursor where appropriate, and fix error codes for retries.
1 parent fbe5a1d commit d9590ea

File tree

5 files changed

+6
-9
lines changed

5 files changed

+6
-9
lines changed

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

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

1919
import static com.google.common.base.MoreObjects.firstNonNull;
2020
import static com.google.common.base.Preconditions.checkArgument;
21-
import static com.google.common.base.Preconditions.checkNotNull;
2221
import static java.nio.charset.StandardCharsets.UTF_8;
2322

2423
import com.google.api.client.extensions.appengine.http.UrlFetchTransport;
@@ -229,8 +228,7 @@ public B clock(Clock clock) {
229228
* @return the builder
230229
*/
231230
public B projectId(String projectId) {
232-
this.projectId =
233-
checkNotNull(projectId, "Project ID cannot be set to null. Leave unset for default.");
231+
this.projectId = projectId;
234232
return self();
235233
}
236234

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreException.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ public class DatastoreException extends BaseServiceException {
3434

3535
// see https://cloud.google.com/datastore/docs/concepts/errors#Error_Codes"
3636
private static final Set<Error> RETRYABLE_ERRORS = ImmutableSet.of(
37-
new Error(409, "ABORTED"),
38-
new Error(403, "DEADLINE_EXCEEDED"),
39-
new Error(503, "UNAVAILABLE"));
37+
new Error(10, "ABORTED"), new Error(4, "DEADLINE_EXCEEDED"), new Error(14, "UNAVAILABLE"));
4038
private static final long serialVersionUID = 2663750991205874435L;
4139

4240
public DatastoreException(int code, String message, String reason, Throwable cause) {

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DateTime.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
106106
com.google.protobuf.Timestamp.parseFrom(bytesPb)));
107107
}
108108

109-
protected static long timestampPbToMicroseconds(com.google.protobuf.Timestamp timestampPb) {
109+
static long timestampPbToMicroseconds(com.google.protobuf.Timestamp timestampPb) {
110110
return timestampPb.getSeconds() * 1000000 + timestampPb.getNanos() / 1000;
111111
}
112112

113-
protected static com.google.protobuf.Timestamp microsecondsToTimestampPb(long microseconds) {
113+
static com.google.protobuf.Timestamp microsecondsToTimestampPb(long microseconds) {
114114
long seconds = microseconds / 1000000;
115115
int nanos = (int) (microseconds % 1000000) * 1000;
116116
return com.google.protobuf.Timestamp.newBuilder().setSeconds(seconds).setNanos(nanos).build();

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/QueryResultsImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ protected T computeNext() {
9393
sendRequest();
9494
}
9595
if (!entityResultPbIter.hasNext()) {
96+
cursor = runQueryResponsePb.getBatch().getEndCursor();
9697
return endOfData();
9798
}
9899
com.google.datastore.v1beta3.EntityResult entityResultPb = entityResultPbIter.next();

gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ public void testRetryableException() throws Exception {
986986
EasyMock.expect(rpcFactoryMock.create(EasyMock.anyObject(DatastoreOptions.class)))
987987
.andReturn(rpcMock);
988988
EasyMock.expect(rpcMock.lookup(requestPb))
989-
.andThrow(new DatastoreException(503, "UNAVAILABLE", "UNAVAILABLE", null))
989+
.andThrow(new DatastoreException(14, "UNAVAILABLE", "UNAVAILABLE", null))
990990
.andReturn(responsePb);
991991
EasyMock.replay(rpcFactoryMock, rpcMock);
992992
DatastoreOptions options = this.options.toBuilder()

0 commit comments

Comments
 (0)