Skip to content

Commit

Permalink
Remove throws IOException that is never thrown in S3Resource meth…
Browse files Browse the repository at this point in the history
…ods (#1222)

It can facilitate the implementation of Comparator based on contentLength or lastModified

Fixes #1108.
---
Co-authored-by: Alexis SEGURA <alexis.segura@akt.io>
  • Loading branch information
alexisgra authored Sep 19, 2024
1 parent 2f78149 commit e7a4cdb
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 e7a4cdb

Please sign in to comment.