From 8f9bd58336f88d9a2d829b9b0a324dc191bba67d Mon Sep 17 00:00:00 2001 From: Alexis SEGURA Date: Thu, 19 Sep 2024 14:15:52 +0200 Subject: [PATCH] Issue-1108: Remove IOException never thrown in S3Resource methods It can facilitate the implementation of Comparator based on contentLength or lastModified --- .../src/main/java/io/awspring/cloud/s3/S3Resource.java | 6 +++--- .../io/awspring/cloud/s3/S3ResourceIntegrationTests.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/S3Resource.java b/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/S3Resource.java index 42a089913..8b3b3afe3 100644 --- a/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/S3Resource.java +++ b/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/S3Resource.java @@ -130,7 +130,7 @@ public boolean exists() { } @Override - public long contentLength() throws IOException { + public long contentLength() { if (headMetadata == null) { fetchMetadata(); } @@ -138,7 +138,7 @@ public long contentLength() throws IOException { } @Override - public long lastModified() throws IOException { + public long lastModified() { if (headMetadata == null) { fetchMetadata(); } @@ -146,7 +146,7 @@ public long lastModified() throws IOException { } @Override - public File getFile() throws IOException { + public File getFile() { throw new UnsupportedOperationException("Amazon S3 resource can not be resolved to java.io.File objects.Use " + "getInputStream() to retrieve the contents of the object!"); } diff --git a/spring-cloud-aws-s3/src/test/java/io/awspring/cloud/s3/S3ResourceIntegrationTests.java b/spring-cloud-aws-s3/src/test/java/io/awspring/cloud/s3/S3ResourceIntegrationTests.java index 66c7af924..765d30c93 100644 --- a/spring-cloud-aws-s3/src/test/java/io/awspring/cloud/s3/S3ResourceIntegrationTests.java +++ b/spring-cloud-aws-s3/src/test/java/io/awspring/cloud/s3/S3ResourceIntegrationTests.java @@ -122,7 +122,7 @@ void existsReturnsFalseWhenObjectDoesNotExist(S3OutputStreamProvider s3OutputStr } @TestAvailableOutputStreamProviders - void objectHasContentLength(S3OutputStreamProvider s3OutputStreamProvider) throws IOException { + void objectHasContentLength(S3OutputStreamProvider s3OutputStreamProvider) { String contents = "test-file-content"; client.putObject(PutObjectRequest.builder().bucket("first-bucket").key("test-file.txt").build(), RequestBody.fromString(contents));