Skip to content

Commit 408806a

Browse files
committed
Optimized stream handling
1 parent fb060fd commit 408806a

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

server/src/main/java/com/adobe/testing/s3mock/store/MultipartStore.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,13 @@ public List<MultipartUpload> listMultipartUploads(BucketMetadata bucketMetadata,
140140
.map(
141141
path -> {
142142
var fileName = path.getFileName().toString();
143-
var uploadMetadata = getUploadMetadata(bucketMetadata, UUID.fromString(fileName));
144-
if (uploadMetadata != null && !uploadMetadata.completed()) {
145-
return uploadMetadata.upload();
146-
} else {
147-
return null;
148-
}
143+
return getUploadMetadata(bucketMetadata, UUID.fromString(fileName));
149144
}
150145
)
151146
.filter(Objects::nonNull)
152-
.filter(multipartUpload -> isBlank(prefix) || multipartUpload.key().startsWith(prefix))
147+
.filter(uploadMetadata -> !uploadMetadata.completed())
148+
.map(MultipartUploadInfo::upload)
149+
.filter(upload -> isBlank(prefix) || upload.key().startsWith(prefix))
153150
.toList();
154151
} catch (IOException e) {
155152
throw new IllegalStateException("Could not load buckets from data directory ", e);

0 commit comments

Comments
 (0)