This is an automated email from the ASF dual-hosted git repository.
gaul pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jclouds.git
The following commit(s) were added to refs/heads/master by this push:
new 94b42fb7b9 Improve parsing of missing S3 bucket errors
94b42fb7b9 is described below
commit 94b42fb7b97f6b578487e0f663020feaaa287b08
Author: Andrew Gaul <[email protected]>
AuthorDate: Mon Dec 23 08:23:02 2024 -0500
Improve parsing of missing S3 bucket errors
Confusingly AWSError is not always parsed so retain the existing
logic. Found via S3Proxy s3-tests with Minio.
---
.../java/org/jclouds/s3/handlers/ParseS3ErrorFromXmlContent.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git
a/apis/s3/src/main/java/org/jclouds/s3/handlers/ParseS3ErrorFromXmlContent.java
b/apis/s3/src/main/java/org/jclouds/s3/handlers/ParseS3ErrorFromXmlContent.java
index ce59adca9d..8148d38fd3 100644
---
a/apis/s3/src/main/java/org/jclouds/s3/handlers/ParseS3ErrorFromXmlContent.java
+++
b/apis/s3/src/main/java/org/jclouds/s3/handlers/ParseS3ErrorFromXmlContent.java
@@ -61,7 +61,7 @@ public class ParseS3ErrorFromXmlContent extends
ParseAWSErrorFromXmlContent {
switch (response.getStatusCode()) {
case 404:
if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
- // TODO: parse NoSuchBucket and NoSuchKey from error?
+ String errorCode = (error != null && error.getCode() != null) ?
error.getCode() : null;
// If we have a payload/bucket/container that is not all
lowercase, vhost-style URLs are not an option
// and must be automatically converted to their path-based
equivalent. This should only be possible for
// AWS-S3 since it is the only S3 implementation configured to
allow uppercase payload/bucket/container
@@ -77,15 +77,16 @@ public class ParseS3ErrorFromXmlContent extends
ParseAWSErrorFromXmlContent {
if (isVhostStyle && !wasPathBasedRequest) {
String container =
command.getCurrentRequest().getEndpoint().getHost();
String key =
command.getCurrentRequest().getEndpoint().getPath();
- if (key == null || key.equals("/"))
+ if ("NoSuchBucket".equals(errorCode) || key == null ||
key.equals("/"))
exception = new ContainerNotFoundException(container,
message);
else
exception = new KeyNotFoundException(container, key,
message);
} else if (command.getCurrentRequest().getEndpoint().getPath()
.indexOf(servicePath.equals("/") ? "/" : servicePath +
"/") == 0) {
String path =
command.getCurrentRequest().getEndpoint().getPath().substring(servicePath.length());
+ // TODO: could parse this out of error.getDetails() using
BucketName and Key
List<String> parts =
newArrayList(Splitter.on('/').omitEmptyStrings().split(path));
- if (parts.size() == 1) {
+ if ("NoSuchBucket".equals(errorCode) || parts.size() == 1) {
exception = new ContainerNotFoundException(parts.get(0),
message);
} else if (parts.size() > 1) {
exception = new KeyNotFoundException(parts.remove(0),
Joiner.on('/').join(parts), message);