Skip to content

Commit 96c80c0

Browse files
author
Ajay Kannan
committed
Remove RemoteGcsHelper exception cast
1 parent 863c572 commit 96c80c0

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

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

Lines changed: 8 additions & 11 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) throws InterruptedException {
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() throws InterruptedException {
178175
while (true) {
179176
for (BlobInfo info : storage.list(bucket).values()) {
180177
storage.delete(bucket, info.name());

0 commit comments

Comments
 (0)