Skip to content
Permalink
Browse files
JCLOUDS-40 unasync Fallback.
  • Loading branch information
Adrian Cole committed Oct 6, 2014
1 parent f0e3375 commit 1c45642d6106949c957e89feb9d0c7ce4955b659
Showing 2 changed files with 0 additions and 18 deletions.
@@ -18,28 +18,18 @@

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;

import org.jclouds.Fallback;

import com.google.common.util.concurrent.ListenableFuture;

/**
* Returns false when encountering an IllegalArgumentException.
*/
public class FalseOnIllegalArgumentException implements Fallback<Boolean> {

@Override
public ListenableFuture<Boolean> create(Throwable t) throws Exception {
return immediateFuture(createOrPropagate(t));
}

@Override
public Boolean createOrPropagate(Throwable t) throws Exception {
if (getFirstThrowableOfType(checkNotNull(t, "throwable"), IllegalArgumentException.class) != null)
return false;
throw propagate(t);
}

}
@@ -17,24 +17,16 @@
package org.jclouds.rds;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.jclouds.Fallbacks.valOnNotFoundOr404;

import org.jclouds.Fallback;
import org.jclouds.aws.AWSResponseException;

import com.google.common.util.concurrent.ListenableFuture;

public final class RDSFallbacks {
private RDSFallbacks() {
}

public static final class NullOnStateDeletingNotFoundOr404 implements Fallback<Object> {
@Override
public ListenableFuture<Object> create(Throwable t) throws Exception {
return immediateFuture(createOrPropagate(t));
}

@Override
public Object createOrPropagate(Throwable t) throws Exception {
if (checkNotNull(t, "throwable") instanceof AWSResponseException) {

0 comments on commit 1c45642

Please sign in to comment.