diff --git a/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/DeleteAllKeysInList.java b/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/DeleteAllKeysInList.java index 86470b5685..c7a5881354 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/DeleteAllKeysInList.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/strategy/internal/DeleteAllKeysInList.java @@ -91,8 +91,13 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr if (options.isRecursive()) message = message + " recursively"; Map exceptions = Maps.newHashMap(); - Iterable toDelete = getResourcesToDelete(containerName, options); + Iterable toDelete; for (int i = 0; i < 3; i++) { // TODO parameterize + toDelete = getResourcesToDelete(containerName, options); + if (Iterables.isEmpty(toDelete)) { + break; + } + Map> responses = Maps.newHashMap(); try { for (final StorageMetadata md : toDelete) { @@ -120,19 +125,15 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr } } finally { exceptions = awaitCompletion(responses, userExecutor, maxTime, logger, message); - toDelete = getResourcesToDelete(containerName, options); - if (Iterables.size(toDelete) == 0) { - break; - } - if (exceptions.size() > 0) { - toDelete = Iterables.concat(exceptions.keySet(), toDelete); - retryHandler.imposeBackoffExponentialDelay(i + 1, message); - } + } + if (!exceptions.isEmpty()) { + retryHandler.imposeBackoffExponentialDelay(i + 1, message); } } - if (exceptions.size() > 0) + if (!exceptions.isEmpty()) throw new BlobRuntimeException(String.format("error %s: %s", message, exceptions)); - assert Iterables.size(toDelete) == 0 : String.format("items remaining %s: %s", message, + toDelete = getResourcesToDelete(containerName, options); + assert Iterables.isEmpty(toDelete) : String.format("items remaining %s: %s", message, toDelete); } @@ -163,4 +164,4 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr return toDelete; } -} \ No newline at end of file +}