From 96c80c063001fbfb3425714d47a0147837702f70 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Mon, 11 Jan 2016 09:32:27 -0800 Subject: [PATCH] Remove RemoteGcsHelper exception cast --- .../storage/testing/RemoteGcsHelper.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java index e8ac3916e3e5..16712fa9fd98 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java @@ -65,7 +65,10 @@ public StorageOptions options() { /** * Deletes a bucket, even if non-empty. Objects in the bucket are listed and deleted until bucket - * deletion succeeds or {@code timeout} expires. + * deletion succeeds or {@code timeout} expires. To allow for the timeout, this method uses a + * separate thread to send the delete requests. Use + * {@link #forceDelete(Storage storage, String bucket)} if spawning an additional thread is + * undesirable, such as in the App Engine production runtime. * * @param storage the storage service to be used to issue requests * @param bucket the bucket to be deleted @@ -89,20 +92,14 @@ public static Boolean forceDelete(Storage storage, String bucket, long timeout, } /** - * Deletes a bucket, even if non-empty. Objects in the bucket are listed and deleted until bucket - * deletion succeeds. This method can be used to delete buckets from within App Engine. Note that - * this method does not set a timeout. + * Deletes a bucket, even if non-empty. This method blocks until the deletion completes or fails. * * @param storage the storage service to be used to issue requests * @param bucket the bucket to be deleted * @throws StorageException if an exception is encountered during bucket deletion */ - public static void forceDelete(Storage storage, String bucket) throws StorageException { - try { - new DeleteBucketTask(storage, bucket).call(); - } catch (Exception e) { - throw (StorageException) e; - } + public static void forceDelete(Storage storage, String bucket) throws InterruptedException { + new DeleteBucketTask(storage, bucket).call(); } /** @@ -174,7 +171,7 @@ public DeleteBucketTask(Storage storage, String bucket) { } @Override - public Boolean call() throws Exception { + public Boolean call() throws InterruptedException { while (true) { for (BlobInfo info : storage.list(bucket).values()) { storage.delete(bucket, info.name());