return; } catch (Throwable throwable) { if (Throwables2.getFirstThrowableOfType(throwable, AuthorizationException.class) != null) { S3ErrorCode code = S3ErrorCode.ACCESS_DENIED; baseRequest.setHandled(true); return; } else if (Throwables2.getFirstThrowableOfType(throwable, TimeoutException.class) != null) { S3ErrorCode code = S3ErrorCode.REQUEST_TIMEOUT;
public static <T> T propagateAuthorizationOrOriginalException(Exception e) { AuthorizationException aex = getFirstThrowableOfType(e, AuthorizationException.class); if (aex != null) throw aex; propagate(e); assert false : "exception should have propagated " + e; return null; }
public static <T> T propagateAuthorizationOrOriginalException(Exception e) { AuthorizationException aex = getFirstThrowableOfType(e, AuthorizationException.class); if (aex != null) throw aex; propagate(e); assert false : "exception should have propagated " + e; return null; }
@Override public Boolean createOrPropagate(Throwable t) throws Exception { if (getFirstThrowableOfType(checkNotNull(t, "throwable"), IllegalStateException.class) != null) return false; if (getFirstThrowableOfType(t, ContainerNotFoundException.class) != null) return true; if (returnValueOnCodeOrNull(t, true, equalTo(404)) != null) return true; throw propagate(t); } }
@VisibleForTesting static <T extends Throwable> T getFirstThrowableOfType(TransformParallelException e, Class<T> clazz) { for (Exception exception : e.getFromToException().values()) { T cause = getFirstThrowableOfType(exception, clazz); if (cause != null) return cause; } return null; }
@Override public Void createOrPropagate(Throwable t) throws Exception { IllegalStateException e = getFirstThrowableOfType(checkNotNull(t, "throwable"), IllegalStateException.class); if (e != null && e.getMessage().indexOf("Unable to find account owner for") != -1) { return null; } else { return valOnNotFoundOr404(null, t); } } }
@VisibleForTesting static <T extends Throwable> T getFirstThrowableOfType(TransformParallelException e, Class<T> clazz) { for (Exception exception : e.getFromToException().values()) { T cause = getFirstThrowableOfType(exception, clazz); if (cause != null) return cause; } return null; }
@Override public Boolean createOrPropagate(Throwable t) throws Exception { AWSResponseException exception = getFirstThrowableOfType(checkNotNull(t, "throwable"), AWSResponseException.class); if (exception != null && exception.getError() != null && exception.getError().getCode() != null) { String code = exception.getError().getCode(); if (code.equals("BucketAlreadyOwnedByYou")) return false; else if (code.equals("OperationAborted") && bucket != null && client.bucketExists(bucket)) return false; } throw propagate(t); }
public void testGetCauseTransformParallel() { Exception aex = createMock(AuthorizationException.class); TransformParallelException pex = new TransformParallelException(ImmutableMap.<Object, Future<?>> of(), ImmutableMap.of("bad", aex), "test"); assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex); }
public void testGetFirstThrowableOfTypeFailTransformParallel() { Exception aex = createMock(TimeoutException.class); TransformParallelException pex = new TransformParallelException(ImmutableMap.<Object, Future<?>> of(), ImmutableMap.of("bad", aex), "test"); assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null); }
public void testGetFirstThrowableOfTypeInnerTransformParallel() { Exception aex = createMock(AuthorizationException.class); TransformParallelException pex = new TransformParallelException(ImmutableMap.<Object, Future<?>> of(), ImmutableMap.of("bad", (Exception) new ExecutionException(aex)), "test"); assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex); }
public void testGetFirstThrowableOfTypeOuterTransformParallel() { Exception aex = createMock(AuthorizationException.class); TransformParallelException pex = new TransformParallelException(ImmutableMap.<Object, Future<?>> of(), ImmutableMap.of("bad", aex), "test"); assertEquals(getFirstThrowableOfType(new ExecutionException(pex), AuthorizationException.class), aex); }
public void testGetFirstThrowableOfTypeFail() { TimeoutException aex = createMock(TimeoutException.class); Message message = new Message(ImmutableList.of(), "test", aex); ProvisionException pex = new ProvisionException(ImmutableSet.of(message)); assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null); }
public void testGetCauseCreation() { AuthorizationException aex = createMock(AuthorizationException.class); Message message = new Message(ImmutableList.of(), "test", aex); CreationException pex = new CreationException(ImmutableSet.of(message)); assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex); }
public void testGetFirstThrowableOfTypeFailCreation() { TimeoutException aex = createMock(TimeoutException.class); Message message = new Message(ImmutableList.of(), "test", aex); CreationException pex = new CreationException(ImmutableSet.of(message)); assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null); }
public void testGetCause() { AuthorizationException aex = createMock(AuthorizationException.class); Message message = new Message(ImmutableList.of(), "test", aex); ProvisionException pex = new ProvisionException(ImmutableSet.of(message)); assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex); }
public void testGetFirstThrowableOfTypeInner() { AuthorizationException aex = createMock(AuthorizationException.class); Message message = new Message(ImmutableList.of(), "test", aex); ProvisionException pex = new ProvisionException(ImmutableSet.of(message)); assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex); }
public void testGetFirstThrowableOfTypeInnerCreation() { AuthorizationException aex = createMock(AuthorizationException.class); Message message = new Message(ImmutableList.of(), "test", aex); CreationException pex = new CreationException(ImmutableSet.of(message)); assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex); }
public void testGetFirstThrowableOfTypeWhenCauseIsNull() { Message message = new Message(ImmutableList.of(), "test", null); ProvisionException pex = new ProvisionException(ImmutableSet.of(message)); assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null); }
public void testGetFirstThrowableOfTypeWhenCauseIsNullCreation() { Message message = new Message(ImmutableList.of(), "test", null); CreationException pex = new CreationException(ImmutableSet.of(message)); assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null); }