Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(s3 dataplane): Fix transfer of empty objects #417

Merged
merged 15 commits into from
Aug 21, 2024
Prev Previous commit
Next Next commit
use predicate instead of method
rafaelmag110 committed Aug 20, 2024
commit 62ef21a588aef4808200177aade729b622607851
Original file line number Diff line number Diff line change
@@ -27,8 +27,8 @@

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@@ -109,7 +109,9 @@ private List<S3Object> fetchPrefixedS3Objects() {

var response = client.listObjectsV2(listObjectsRequest);

s3Objects.addAll(filterOutFolderFile(response.contents()));
Predicate<S3Object> isFile = object -> !object.key().endsWith("/");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be a class field or constant, so it won't be recreated each time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in a6645ac


s3Objects.addAll(response.contents().stream().filter(isFile).collect(Collectors.toList()));

continuationToken = response.nextContinuationToken();

@@ -118,10 +120,6 @@ private List<S3Object> fetchPrefixedS3Objects() {
return s3Objects;
}

private Collection<S3Object> filterOutFolderFile(List<S3Object> contents) {
return contents.stream().filter(object -> !object.key().endsWith("/")).collect(Collectors.toSet());
}

@Override
public void close() {
client.close();