File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed
src/main/java/me/aneeshneelam/lib/aws/s3/v2 Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 1414}
1515
1616group = ' me.aneeshneelam'
17- version = ' 1.0 '
17+ version = ' 1.1 '
1818
1919java {
2020 sourceCompatibility JavaVersion . VERSION_1_8
Original file line number Diff line number Diff line change @@ -62,21 +62,21 @@ private void setListObjectsV2ResponsePaginationState(ListObjectsV2Response listO
6262
6363 @ Override
6464 public boolean hasNext () {
65- try {
66- return this .checkListObjectsV2ResponseState ()
67- .thenApply (aVoid -> this .s3ObjectIterator .hasNext ())
68- .get (requestTimeoutDuration .getSeconds (), TimeUnit .SECONDS );
69- } catch (InterruptedException | ExecutionException | TimeoutException e ) {
70- throw new RuntimeException (e );
71- }
65+ CompletableFuture <Boolean > booleanCompletableFuture = this .checkListObjectsV2ResponseState ()
66+ .thenApply (aVoid -> this .s3ObjectIterator .hasNext ());
67+ return this .completableFutureGet (booleanCompletableFuture );
7268 }
7369
7470 @ Override
7571 public S3Object next () {
72+ CompletableFuture <S3Object > s3ObjectCompletableFuture = this .checkListObjectsV2ResponseState ()
73+ .thenApply (aVoid -> this .s3ObjectIterator .next ());
74+ return this .completableFutureGet (s3ObjectCompletableFuture );
75+ }
76+
77+ private <T > T completableFutureGet (CompletableFuture <T > completableFuture ) {
7678 try {
77- return this .checkListObjectsV2ResponseState ()
78- .thenApply (aVoid -> this .s3ObjectIterator .next ())
79- .get (requestTimeoutDuration .getSeconds (), TimeUnit .SECONDS );
79+ return completableFuture .get (this .requestTimeoutDuration .getSeconds (), TimeUnit .SECONDS );
8080 } catch (InterruptedException | ExecutionException | TimeoutException e ) {
8181 throw new RuntimeException (e );
8282 }
You can’t perform that action at this time.
0 commit comments