diff --git a/src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java b/src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java index a33678943c..0f093f0725 100644 --- a/src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java +++ b/src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java @@ -1147,17 +1147,17 @@ public class S3Controller { private Response handleGetBucketLocation(String bucket) { String region = s3Service.getBucketRegion(bucket); - XmlBuilder xml = new XmlBuilder() - .raw(""); + String xml; if (region == null || "us-east-1".equals(region)) { - xml.start("LocationConstraint", AwsNamespaces.S3) - .end("LocationConstraint"); + xml = ""; } else { - xml.start("LocationConstraint", AwsNamespaces.S3) + xml = new XmlBuilder() + .start("LocationConstraint", AwsNamespaces.S3) .raw(XmlBuilder.escape(region)) - .end("LocationConstraint"); + .end("LocationConstraint") + .build(); } - return Response.ok(xml.build()).type(MediaType.APPLICATION_XML).build(); + return Response.ok(xml).type(MediaType.APPLICATION_XML).build(); } // --- Bucket Tagging --- diff --git a/src/test/java/io/github/hectorvent/floci/services/s3/S3IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/s3/S3IntegrationTest.java index d1324e6756..4ce1445ed9 100644 --- a/src/test/java/io/github/hectorvent/floci/services/s3/S3IntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/s3/S3IntegrationTest.java @@ -1289,6 +1289,7 @@ class S3IntegrationTest { .get("/" + bucket + "?location") .then() .statusCode(200) + .body(not(containsString("