Skip to content

Commit 10b38c3

Browse files
committed
fix: close resource
1 parent e9401a3 commit 10b38c3

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/main/java/io/papermc/fill/service/StorageServiceImpl.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,12 @@ public void putObject(
114114
.bucket(properties.s3().bucket())
115115
.key(path)
116116
.build();
117-
final ResponseInputStream<GetObjectResponse> response;
118-
try {
119-
response = this.s3.getObject(request);
117+
try (final ResponseInputStream<GetObjectResponse> response = this.s3.getObject(request)) {
118+
LOGGER.debug("Retrieved object {} from bucket", download);
119+
final byte[] bytes = response.readAllBytes();
120+
yield new Asset(bytes, HttpHeaders.EMPTY);
120121
} catch (final S3Exception e) {
121122
throw createStorageReadException(download, path, "s3 exception", e);
122-
}
123-
LOGGER.debug("Retrieved object {} from bucket", download);
124-
try {
125-
yield new Asset(response.readAllBytes(), HttpHeaders.EMPTY);
126123
} catch (final IOException e) {
127124
throw createStorageReadException(download, path, "i/o exception", e);
128125
}

0 commit comments

Comments
 (0)