Skip to content

Commit

Permalink
Issue-1108: Remove IOException never thrown in S3Resource methods
Browse files Browse the repository at this point in the history
It can facilitate the implementation of Comparator based on contentLength or lastModified
  • Loading branch information
Alexis SEGURA committed Sep 19, 2024
1 parent b5df124 commit 8f9bd58
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,23 @@ public boolean exists() {
}

@Override
public long contentLength() throws IOException {
public long contentLength() {
if (headMetadata == null) {
fetchMetadata();
}
return headMetadata.contentLength;
}

@Override
public long lastModified() throws IOException {
public long lastModified() {
if (headMetadata == null) {
fetchMetadata();
}
return headMetadata.lastModified.toEpochMilli();
}

@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!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 8f9bd58

Please sign in to comment.