You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2014/01/29 19:30:23 UTC
git commit: Store propagatable exceptions in a static field
Updated Branches:
refs/heads/master 52f25fd28 -> 241abea73
Store propagatable exceptions in a static field
Also include ResourceAlreadyExistsException. References JCLOUDS-438.
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/241abea7
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/241abea7
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/241abea7
Branch: refs/heads/master
Commit: 241abea734b8b3354c82a2241c93ec04cc6bbf3c
Parents: 52f25fd
Author: Andrew Gaul <ga...@apache.org>
Authored: Wed Jan 29 09:02:39 2014 -0800
Committer: Andrew Gaul <ga...@apache.org>
Committed: Wed Jan 29 10:30:18 2014 -0800
----------------------------------------------------------------------
.../main/java/org/jclouds/util/Throwables2.java | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/241abea7/core/src/main/java/org/jclouds/util/Throwables2.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/util/Throwables2.java b/core/src/main/java/org/jclouds/util/Throwables2.java
index 309153e..cf0e9b1 100644
--- a/core/src/main/java/org/jclouds/util/Throwables2.java
+++ b/core/src/main/java/org/jclouds/util/Throwables2.java
@@ -27,10 +27,12 @@ import org.jclouds.concurrent.TransformParallelException;
import org.jclouds.http.HttpResponseException;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.InsufficientResourcesException;
+import org.jclouds.rest.ResourceAlreadyExistsException;
import org.jclouds.rest.ResourceNotFoundException;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
import com.google.common.reflect.TypeToken;
import com.google.inject.CreationException;
import com.google.inject.ProvisionException;
@@ -125,8 +127,19 @@ public class Throwables2 {
return null;
}
+ // Note that ordering matters to propagateIfPossible.
+ private static final ImmutableList<Class<? extends Throwable>> PROPAGATABLE_EXCEPTION_TYPES = ImmutableList.of(
+ IllegalStateException.class,
+ AssertionError.class,
+ UnsupportedOperationException.class,
+ IllegalArgumentException.class,
+ AuthorizationException.class,
+ ResourceAlreadyExistsException.class,
+ ResourceNotFoundException.class,
+ InsufficientResourcesException.class,
+ HttpResponseException.class);
+
// Note this needs to be kept up-to-date with all top-level exceptions jclouds works against
- @SuppressWarnings("unchecked")
public static void propagateIfPossible(Throwable exception, Iterable<TypeToken<? extends Throwable>> throwables)
throws Throwable {
for (TypeToken<? extends Throwable> type : throwables) {
@@ -135,10 +148,7 @@ public class Throwables2 {
throw throwable;
}
}
- for (Class<Exception> propagatableExceptionType : new Class[] { IllegalStateException.class,
- AssertionError.class, UnsupportedOperationException.class, IllegalArgumentException.class,
- AuthorizationException.class, ResourceNotFoundException.class, InsufficientResourcesException.class,
- HttpResponseException.class }) {
+ for (Class<? extends Throwable> propagatableExceptionType : PROPAGATABLE_EXCEPTION_TYPES) {
Throwable throwable = Throwables2.getFirstThrowableOfType(exception, propagatableExceptionType);
if (throwable != null) {
throw throwable;