mirror of https://github.com/apache/jclouds.git
s3 error parse regression
This commit is contained in:
parent
1e017d47e1
commit
f1288fed4c
|
@ -53,7 +53,7 @@ import org.jclouds.s3.functions.ObjectKey;
|
||||||
import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent;
|
import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent;
|
||||||
import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders;
|
import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders;
|
||||||
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
|
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
|
||||||
import org.jclouds.s3.functions.ReturnTrueOn404OrNotFoundFalseIfNotEmpty;
|
import org.jclouds.s3.functions.ReturnTrueOn404OrNotFoundFalseOnIllegalState;
|
||||||
import org.jclouds.s3.options.CopyObjectOptions;
|
import org.jclouds.s3.options.CopyObjectOptions;
|
||||||
import org.jclouds.s3.options.ListBucketOptions;
|
import org.jclouds.s3.options.ListBucketOptions;
|
||||||
import org.jclouds.s3.options.PutBucketOptions;
|
import org.jclouds.s3.options.PutBucketOptions;
|
||||||
|
@ -182,7 +182,7 @@ public interface S3AsyncClient {
|
||||||
*/
|
*/
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@ExceptionParser(ReturnTrueOn404OrNotFoundFalseIfNotEmpty.class)
|
@ExceptionParser(ReturnTrueOn404OrNotFoundFalseOnIllegalState.class)
|
||||||
ListenableFuture<Boolean> deleteBucketIfEmpty(
|
ListenableFuture<Boolean> deleteBucketIfEmpty(
|
||||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName);
|
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName);
|
||||||
|
|
||||||
|
|
|
@ -20,18 +20,12 @@
|
||||||
package org.jclouds.s3.functions;
|
package org.jclouds.s3.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Predicates.equalTo;
|
import static com.google.common.base.Predicates.equalTo;
|
||||||
import static com.google.common.base.Throwables.getCausalChain;
|
|
||||||
import static com.google.common.collect.Iterables.filter;
|
|
||||||
import static com.google.common.collect.Iterables.get;
|
|
||||||
import static com.google.common.collect.Iterables.size;
|
|
||||||
import static org.jclouds.http.HttpUtils.returnValueOnCodeOrNull;
|
import static org.jclouds.http.HttpUtils.returnValueOnCodeOrNull;
|
||||||
|
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
|
||||||
import static org.jclouds.util.Throwables2.propagateOrNull;
|
import static org.jclouds.util.Throwables2.propagateOrNull;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.AWSResponseException;
|
|
||||||
import org.jclouds.blobstore.ContainerNotFoundException;
|
import org.jclouds.blobstore.ContainerNotFoundException;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -41,20 +35,13 @@ import com.google.common.base.Function;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ReturnTrueOn404OrNotFoundFalseIfNotEmpty implements Function<Exception, Boolean> {
|
public class ReturnTrueOn404OrNotFoundFalseOnIllegalState implements Function<Exception, Boolean> {
|
||||||
|
|
||||||
public Boolean apply(Exception from) {
|
public Boolean apply(Exception from) {
|
||||||
List<Throwable> throwables = getCausalChain(from);
|
if (getFirstThrowableOfType(from, IllegalStateException.class) != null) {
|
||||||
|
return false;
|
||||||
Iterable<AWSResponseException> matchingAWSResponseException = filter(throwables, AWSResponseException.class);
|
|
||||||
if (size(matchingAWSResponseException) >= 1 && get(matchingAWSResponseException, 0).getError() != null) {
|
|
||||||
if (get(matchingAWSResponseException, 0).getError().getCode().equals("BucketNotEmpty"))
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
if (getFirstThrowableOfType(from, ContainerNotFoundException.class) != null) {
|
||||||
Iterable<ContainerNotFoundException> matchingContainerNotFoundException = filter(throwables,
|
|
||||||
ContainerNotFoundException.class);
|
|
||||||
if (size(matchingContainerNotFoundException) >= 1) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (returnValueOnCodeOrNull(from, true, equalTo(404)) != null)
|
if (returnValueOnCodeOrNull(from, true, equalTo(404)) != null)
|
|
@ -38,7 +38,7 @@ import org.jclouds.s3.domain.AccessControlList.Permission;
|
||||||
import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent;
|
import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent;
|
||||||
import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders;
|
import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders;
|
||||||
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
|
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
|
||||||
import org.jclouds.s3.functions.ReturnTrueOn404OrNotFoundFalseIfNotEmpty;
|
import org.jclouds.s3.functions.ReturnTrueOn404OrNotFoundFalseOnIllegalState;
|
||||||
import org.jclouds.s3.options.CopyObjectOptions;
|
import org.jclouds.s3.options.CopyObjectOptions;
|
||||||
import org.jclouds.s3.options.ListBucketOptions;
|
import org.jclouds.s3.options.ListBucketOptions;
|
||||||
import org.jclouds.s3.options.PutBucketOptions;
|
import org.jclouds.s3.options.PutBucketOptions;
|
||||||
|
@ -231,7 +231,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
|
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
assertExceptionParserClassEquals(method, ReturnTrueOn404OrNotFoundFalseIfNotEmpty.class);
|
assertExceptionParserClassEquals(method, ReturnTrueOn404OrNotFoundFalseOnIllegalState.class);
|
||||||
|
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue