diff --git a/spring-cloud-aws-s3-parent/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/S3PathMatchingResourcePatternResolver.java b/spring-cloud-aws-s3-parent/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/S3PathMatchingResourcePatternResolver.java index 2bb3e9520..f45ec5cb2 100644 --- a/spring-cloud-aws-s3-parent/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/S3PathMatchingResourcePatternResolver.java +++ b/spring-cloud-aws-s3-parent/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/S3PathMatchingResourcePatternResolver.java @@ -227,7 +227,7 @@ private ListObjectsV2Request.Builder getListObjectsV2RequestBuilder(String s3Buc PATH_DELIMITER)) .findFirst(); ListObjectsV2Request.Builder listObjectsV2RequestBuilder = ListObjectsV2Request.builder().bucket(s3BucketName); - if (optionalPrefix.isPresent()) { + if (optionalPrefix.isPresent() && !"/".equals(optionalPrefix.get())) { listObjectsV2RequestBuilder = listObjectsV2RequestBuilder.prefix(optionalPrefix.get()); } return listObjectsV2RequestBuilder;