Skip to content

Commit

Permalink
Updated AsyncS3ObjectIterator to improve code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
aneesh-neelam committed Aug 23, 2024
1 parent 1792986 commit f0c7138
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ext {
}

group = 'me.aneeshneelam'
version = '1.0'
version = '1.1'

java {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ private void setListObjectsV2ResponsePaginationState(ListObjectsV2Response listO

@Override
public boolean hasNext() {
try {
return this.checkListObjectsV2ResponseState()
.thenApply(aVoid -> this.s3ObjectIterator.hasNext())
.get(requestTimeoutDuration.getSeconds(), TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
throw new RuntimeException(e);
}
CompletableFuture<Boolean> booleanCompletableFuture = this.checkListObjectsV2ResponseState()
.thenApply(aVoid -> this.s3ObjectIterator.hasNext());
return this.completableFutureGet(booleanCompletableFuture);
}

@Override
public S3Object next() {
CompletableFuture<S3Object> s3ObjectCompletableFuture = this.checkListObjectsV2ResponseState()
.thenApply(aVoid -> this.s3ObjectIterator.next());
return this.completableFutureGet(s3ObjectCompletableFuture);
}

private <T> T completableFutureGet(CompletableFuture<T> completableFuture) {
try {
return this.checkListObjectsV2ResponseState()
.thenApply(aVoid -> this.s3ObjectIterator.next())
.get(requestTimeoutDuration.getSeconds(), TimeUnit.SECONDS);
return completableFuture.get(this.requestTimeoutDuration.getSeconds(), TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit f0c7138

Please sign in to comment.