Skip to content

Commit ff2e15e

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 2153 b: refs/heads/pubsub-alpha c: 33f6ad8 h: refs/heads/master i: 2151: 7480caa
1 parent 6ee56dc commit ff2e15e

3 files changed

Lines changed: 17 additions & 16 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ refs/heads/master: 689bbb466df4b2d5d2483d6edb8ac5c7c7f7c6fa
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: 4e0561bb4504bf647db669a14417b2b2c87ba45d
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3
6-
refs/heads/pubsub-alpha: 863c57270d177fd0ccbc0dd6b84083ab2777f983
6+
refs/heads/pubsub-alpha: 33f6ad862077eb45a9dec040e45a899cc462cbf6
77
refs/heads/resource-manager: ebf4adc5ee835cd2086c4ac5b4e78d01a5a005a7
88
refs/heads/update-datastore: 482954f2c5055231e5b3122ea91d2ba00ce8187c
99
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444

branches/pubsub-alpha/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ public StorageOptions options() {
6565

6666
/**
6767
* Deletes a bucket, even if non-empty. Objects in the bucket are listed and deleted until bucket
68-
* deletion succeeds or {@code timeout} expires.
68+
* deletion succeeds or {@code timeout} expires. To allow for the timeout, this method uses a
69+
* separate thread to send the delete requests. Use
70+
* {@link #forceDelete(Storage storage, String bucket)} if spawning an additional thread is
71+
* undesirable, such as in the App Engine production runtime.
6972
*
7073
* @param storage the storage service to be used to issue requests
7174
* @param bucket the bucket to be deleted
@@ -89,20 +92,14 @@ public static Boolean forceDelete(Storage storage, String bucket, long timeout,
8992
}
9093

9194
/**
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+
* Deletes a bucket, even if non-empty. This method blocks until the deletion completes or fails.
9596
*
9697
* @param storage the storage service to be used to issue requests
9798
* @param bucket the bucket to be deleted
9899
* @throws StorageException if an exception is encountered during bucket deletion
99100
*/
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-
}
101+
public static void forceDelete(Storage storage, String bucket) {
102+
new DeleteBucketTask(storage, bucket).call();
106103
}
107104

108105
/**
@@ -174,7 +171,7 @@ public DeleteBucketTask(Storage storage, String bucket) {
174171
}
175172

176173
@Override
177-
public Boolean call() throws Exception {
174+
public Boolean call() {
178175
while (true) {
179176
for (BlobInfo info : storage.list(bucket).values()) {
180177
storage.delete(bucket, info.name());
@@ -184,7 +181,12 @@ public Boolean call() throws Exception {
184181
return true;
185182
} catch (StorageException e) {
186183
if (e.code() == 409) {
187-
Thread.sleep(500);
184+
try {
185+
Thread.sleep(500);
186+
} catch (InterruptedException interruptedException) {
187+
Thread.currentThread().interrupt();
188+
throw e;
189+
}
188190
} else {
189191
throw e;
190192
}

branches/pubsub-alpha/gcloud-java-storage/src/test/java/com/google/gcloud/storage/RemoteGcsHelperTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,8 @@ public void testForceDeleteFail() throws InterruptedException, ExecutionExceptio
140140
}
141141
}
142142

143-
144143
@Test
145-
public void testForceDeleteNoTimeout() throws Exception {
144+
public void testForceDeleteNoTimeout() {
146145
Storage storageMock = EasyMock.createMock(Storage.class);
147146
EasyMock.expect(storageMock.list(BUCKET_NAME)).andReturn(BLOB_PAGE);
148147
for (BlobInfo info : BLOB_LIST) {
@@ -155,7 +154,7 @@ public void testForceDeleteNoTimeout() throws Exception {
155154
}
156155

157156
@Test
158-
public void testForceDeleteNoTimeoutFail() throws Exception {
157+
public void testForceDeleteNoTimeoutFail() {
159158
Storage storageMock = EasyMock.createMock(Storage.class);
160159
EasyMock.expect(storageMock.list(BUCKET_NAME)).andReturn(BLOB_PAGE);
161160
for (BlobInfo info : BLOB_LIST) {

0 commit comments

Comments
 (0)