Skip to content

Commit 97cf600

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 1555 b: refs/heads/master c: 863c572 h: refs/heads/master i: 1553: 5f3d552 1551: 2614531
1 parent 4ea9711 commit 97cf600

8 files changed

Lines changed: 58 additions & 15 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 560faa9e638dbad5c55d53b93c12843c08e361d1
2+
refs/heads/master: 863c57270d177fd0ccbc0dd6b84083ab2777f983
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: d1b373c30c176edc08692348167bec3a244bb823
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3

trunk/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:

trunk/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;

trunk/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

trunk/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
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ public void testRetryableException() throws Exception {
734734
EasyMock.expect(rpcFactoryMock.create(EasyMock.anyObject(DatastoreOptions.class)))
735735
.andReturn(rpcMock);
736736
EasyMock.expect(rpcMock.lookup(requestPb))
737-
.andThrow(new DatastoreRpc.DatastoreRpcException(Reason.UNAVAILABLE, null))
737+
.andThrow(new DatastoreRpc.DatastoreRpcException(Reason.UNAVAILABLE))
738738
.andReturn(responsePb);
739739
EasyMock.replay(rpcFactoryMock, rpcMock);
740740
DatastoreOptions options = this.options.toBuilder()
@@ -756,7 +756,7 @@ public void testNonRetryableException() throws Exception {
756756
EasyMock.expect(rpcFactoryMock.create(EasyMock.anyObject(DatastoreOptions.class)))
757757
.andReturn(rpcMock);
758758
EasyMock.expect(rpcMock.lookup(requestPb))
759-
.andThrow(new DatastoreRpc.DatastoreRpcException(Reason.PERMISSION_DENIED, null))
759+
.andThrow(new DatastoreRpc.DatastoreRpcException(Reason.PERMISSION_DENIED))
760760
.times(1);
761761
EasyMock.replay(rpcFactoryMock, rpcMock);
762762
RetryParams retryParams = RetryParams.builder().retryMinAttempts(2).build();

trunk/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,23 @@ public static Boolean forceDelete(Storage storage, String bucket, long timeout,
8888
}
8989
}
9090

91+
/**
92+
* Deletes a bucket, even if non-empty. Objects in the bucket are listed and deleted until bucket
93+
* deletion succeeds. This method can be used to delete buckets from within App Engine. Note that
94+
* this method does not set a timeout.
95+
*
96+
* @param storage the storage service to be used to issue requests
97+
* @param bucket the bucket to be deleted
98+
* @throws StorageException if an exception is encountered during bucket deletion
99+
*/
100+
public static void forceDelete(Storage storage, String bucket) throws StorageException {
101+
try {
102+
new DeleteBucketTask(storage, bucket).call();
103+
} catch (Exception e) {
104+
throw (StorageException) e;
105+
}
106+
}
107+
91108
/**
92109
* Returns a bucket name generated using a random UUID.
93110
*/

trunk/gcloud-java-storage/src/test/java/com/google/gcloud/storage/RemoteGcsHelperTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,37 @@ public void testForceDeleteFail() throws InterruptedException, ExecutionExceptio
140140
}
141141
}
142142

143+
144+
@Test
145+
public void testForceDeleteNoTimeout() throws Exception {
146+
Storage storageMock = EasyMock.createMock(Storage.class);
147+
EasyMock.expect(storageMock.list(BUCKET_NAME)).andReturn(BLOB_PAGE);
148+
for (BlobInfo info : BLOB_LIST) {
149+
EasyMock.expect(storageMock.delete(BUCKET_NAME, info.name())).andReturn(true);
150+
}
151+
EasyMock.expect(storageMock.delete(BUCKET_NAME)).andReturn(true);
152+
EasyMock.replay(storageMock);
153+
RemoteGcsHelper.forceDelete(storageMock, BUCKET_NAME);
154+
EasyMock.verify(storageMock);
155+
}
156+
157+
@Test
158+
public void testForceDeleteNoTimeoutFail() throws Exception {
159+
Storage storageMock = EasyMock.createMock(Storage.class);
160+
EasyMock.expect(storageMock.list(BUCKET_NAME)).andReturn(BLOB_PAGE);
161+
for (BlobInfo info : BLOB_LIST) {
162+
EasyMock.expect(storageMock.delete(BUCKET_NAME, info.name())).andReturn(true);
163+
}
164+
EasyMock.expect(storageMock.delete(BUCKET_NAME)).andThrow(FATAL_EXCEPTION);
165+
EasyMock.replay(storageMock);
166+
thrown.expect(StorageException.class);
167+
try {
168+
RemoteGcsHelper.forceDelete(storageMock, BUCKET_NAME);
169+
} finally {
170+
EasyMock.verify(storageMock);
171+
}
172+
}
173+
143174
@Test
144175
public void testCreateFromStream() {
145176
RemoteGcsHelper helper = RemoteGcsHelper.create(PROJECT_ID, JSON_KEY_STREAM);

0 commit comments

Comments
 (0)