Skip to content

Commit

Permalink
Fix: correct limit checks for S3Container refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: bansvaru <[email protected]>
  • Loading branch information
linuxpi committed Sep 1, 2023
1 parent ee470bc commit a76be11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,11 @@ public List<BlobMetadata> listBlobsByPrefixInSortedOrder(String blobNamePrefix,
}
String prefix = blobNamePrefix == null ? keyPath : buildKey(blobNamePrefix);
try (AmazonS3Reference clientReference = blobStore.clientReference()) {
return executeListing(clientReference, listObjectsRequest(prefix, limit), limit).stream()
List<BlobMetadata> blobs = executeListing(clientReference, listObjectsRequest(prefix, limit), limit).stream()
.flatMap(listing -> listing.contents().stream())
.map(s3Object -> new PlainBlobMetadata(s3Object.key().substring(keyPath.length()), s3Object.size()))
.collect(Collectors.toList());
return blobs.subList(0, Math.min(limit, blobs.size()));
} catch (final Exception e) {
throw new IOException("Exception when listing blobs by prefix [" + prefix + "]", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ default void listBlobsByPrefixInSortedOrder(
BlobNameSortOrder blobNameSortOrder,
ActionListener<List<BlobMetadata>> listener
) {
if (limit < 0) {
throw new IllegalArgumentException("limit should not be a negative value");
}
try {
listener.onResponse(listBlobsByPrefixInSortedOrder(blobNamePrefix, limit, blobNameSortOrder));
} catch (Exception e) {
Expand Down

0 comments on commit a76be11

Please sign in to comment.