Skip to content

Commit 0ac5f8e

Browse files
committed
Make paginator resume method private
1 parent 76779eb commit 0ac5f8e

File tree

10 files changed

+32
-114
lines changed

10 files changed

+32
-114
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"category": "AWS SDK for Java v2",
3+
"type": "removal",
4+
"description": "Make paginators resume method private.(We will re-add the feature in the future)"
5+
}

codegen/src/main/java/software/amazon/awssdk/codegen/poet/paginators/AsyncResponseClassSpec.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,18 @@ private FieldSpec lastPageField() {
114114
private MethodSpec publicConstructor() {
115115
return MethodSpec.constructorBuilder()
116116
.addModifiers(Modifier.PUBLIC)
117-
.addParameter(getAsyncClientInterfaceName(), CLIENT_MEMBER, Modifier.FINAL)
118-
.addParameter(requestType(), REQUEST_MEMBER, Modifier.FINAL)
117+
.addParameter(getAsyncClientInterfaceName(), CLIENT_MEMBER)
118+
.addParameter(requestType(), REQUEST_MEMBER)
119119
.addStatement("this($L, $L, false)", CLIENT_MEMBER, REQUEST_MEMBER)
120120
.build();
121121
}
122122

123123
private MethodSpec privateConstructor() {
124124
return MethodSpec.constructorBuilder()
125125
.addModifiers(Modifier.PRIVATE)
126-
.addParameter(getAsyncClientInterfaceName(), CLIENT_MEMBER, Modifier.FINAL)
127-
.addParameter(requestType(), REQUEST_MEMBER, Modifier.FINAL)
128-
.addParameter(boolean.class, LAST_PAGE_FIELD, Modifier.FINAL)
126+
.addParameter(getAsyncClientInterfaceName(), CLIENT_MEMBER)
127+
.addParameter(requestType(), REQUEST_MEMBER)
128+
.addParameter(boolean.class, LAST_PAGE_FIELD)
129129
.addStatement("this.$L = $L", CLIENT_MEMBER, CLIENT_MEMBER)
130130
.addStatement("this.$L = $L", REQUEST_MEMBER, REQUEST_MEMBER)
131131
.addStatement("this.$L = $L", LAST_PAGE_FIELD, LAST_PAGE_FIELD)

codegen/src/main/java/software/amazon/awssdk/codegen/poet/paginators/PaginatorsClassSpec.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ protected String nextPageFetcherClassName() {
9595

9696
protected MethodSpec.Builder resumeMethodBuilder() {
9797
return MethodSpec.methodBuilder(RESUME_METHOD)
98-
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
99-
.addParameter(responseType(), LAST_SUCCESSFUL_PAGE_LITERAL, Modifier.FINAL)
98+
.addModifiers(Modifier.PRIVATE, Modifier.FINAL)
99+
.addParameter(responseType(), LAST_SUCCESSFUL_PAGE_LITERAL)
100100
.returns(className())
101101
.addCode(CodeBlock.builder()
102102
.beginControlFlow("if ($L.$L($L))", NEXT_PAGE_FETCHER_MEMBER,

codegen/src/main/java/software/amazon/awssdk/codegen/poet/paginators/SyncResponseClassSpec.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ private FieldSpec syncPageFetcherField() {
100100
private MethodSpec constructor() {
101101
return MethodSpec.constructorBuilder()
102102
.addModifiers(Modifier.PUBLIC)
103-
.addParameter(getClientInterfaceName(), CLIENT_MEMBER, Modifier.FINAL)
104-
.addParameter(requestType(), REQUEST_MEMBER, Modifier.FINAL)
103+
.addParameter(getClientInterfaceName(), CLIENT_MEMBER)
104+
.addParameter(requestType(), REQUEST_MEMBER)
105105
.addStatement("this.$L = $L", CLIENT_MEMBER, CLIENT_MEMBER)
106106
.addStatement("this.$L = $L", REQUEST_MEMBER, REQUEST_MEMBER)
107107
.addStatement("this.$L = new $L()", NEXT_PAGE_FETCHER_MEMBER, nextPageFetcherClassName())

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/paginators/PaginatedOperationWithResultKeyIterable.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public class PaginatedOperationWithResultKeyIterable implements SdkIterable<Pagi
7575

7676
private final SyncPageFetcher nextPageFetcher;
7777

78-
public PaginatedOperationWithResultKeyIterable(final JsonProtocolTestsClient client,
79-
final PaginatedOperationWithResultKeyRequest firstRequest) {
78+
public PaginatedOperationWithResultKeyIterable(JsonProtocolTestsClient client,
79+
PaginatedOperationWithResultKeyRequest firstRequest) {
8080
this.client = client;
8181
this.firstRequest = firstRequest;
8282
this.nextPageFetcher = new PaginatedOperationWithResultKeyResponseFetcher();
@@ -113,7 +113,7 @@ public final SdkIterable<SimpleStruct> items() {
113113
* retrieve the consecutive pages that follows the input page.
114114
* </p>
115115
*/
116-
public final PaginatedOperationWithResultKeyIterable resume(final PaginatedOperationWithResultKeyResponse lastSuccessfulPage) {
116+
private final PaginatedOperationWithResultKeyIterable resume(PaginatedOperationWithResultKeyResponse lastSuccessfulPage) {
117117
if (nextPageFetcher.hasNextPage(lastSuccessfulPage)) {
118118
return new PaginatedOperationWithResultKeyIterable(client, firstRequest.toBuilder()
119119
.nextToken(lastSuccessfulPage.nextToken()).build());

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/paginators/PaginatedOperationWithResultKeyPublisher.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ public class PaginatedOperationWithResultKeyPublisher implements SdkPublisher<Pa
7878

7979
private boolean isLastPage;
8080

81-
public PaginatedOperationWithResultKeyPublisher(final JsonProtocolTestsAsyncClient client,
82-
final PaginatedOperationWithResultKeyRequest firstRequest) {
81+
public PaginatedOperationWithResultKeyPublisher(JsonProtocolTestsAsyncClient client,
82+
PaginatedOperationWithResultKeyRequest firstRequest) {
8383
this(client, firstRequest, false);
8484
}
8585

86-
private PaginatedOperationWithResultKeyPublisher(final JsonProtocolTestsAsyncClient client,
87-
final PaginatedOperationWithResultKeyRequest firstRequest, final boolean isLastPage) {
86+
private PaginatedOperationWithResultKeyPublisher(JsonProtocolTestsAsyncClient client,
87+
PaginatedOperationWithResultKeyRequest firstRequest, boolean isLastPage) {
8888
this.client = client;
8989
this.firstRequest = firstRequest;
9090
this.isLastPage = isLastPage;
@@ -118,7 +118,7 @@ public final SdkPublisher<SimpleStruct> items() {
118118
* retrieve the consecutive pages that follows the input page.
119119
* </p>
120120
*/
121-
public final PaginatedOperationWithResultKeyPublisher resume(final PaginatedOperationWithResultKeyResponse lastSuccessfulPage) {
121+
private final PaginatedOperationWithResultKeyPublisher resume(PaginatedOperationWithResultKeyResponse lastSuccessfulPage) {
122122
if (nextPageFetcher.hasNextPage(lastSuccessfulPage)) {
123123
return new PaginatedOperationWithResultKeyPublisher(client, firstRequest.toBuilder()
124124
.nextToken(lastSuccessfulPage.nextToken()).build());

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/paginators/PaginatedOperationWithoutResultKeyIterable.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public class PaginatedOperationWithoutResultKeyIterable implements SdkIterable<P
7272

7373
private final SyncPageFetcher nextPageFetcher;
7474

75-
public PaginatedOperationWithoutResultKeyIterable(final JsonProtocolTestsClient client,
76-
final PaginatedOperationWithoutResultKeyRequest firstRequest) {
75+
public PaginatedOperationWithoutResultKeyIterable(JsonProtocolTestsClient client,
76+
PaginatedOperationWithoutResultKeyRequest firstRequest) {
7777
this.client = client;
7878
this.firstRequest = firstRequest;
7979
this.nextPageFetcher = new PaginatedOperationWithoutResultKeyResponseFetcher();
@@ -91,8 +91,8 @@ public Iterator<PaginatedOperationWithoutResultKeyResponse> iterator() {
9191
* retrieve the consecutive pages that follows the input page.
9292
* </p>
9393
*/
94-
public final PaginatedOperationWithoutResultKeyIterable resume(
95-
final PaginatedOperationWithoutResultKeyResponse lastSuccessfulPage) {
94+
private final PaginatedOperationWithoutResultKeyIterable resume(
95+
PaginatedOperationWithoutResultKeyResponse lastSuccessfulPage) {
9696
if (nextPageFetcher.hasNextPage(lastSuccessfulPage)) {
9797
return new PaginatedOperationWithoutResultKeyIterable(client, firstRequest.toBuilder()
9898
.nextToken(lastSuccessfulPage.nextToken()).build());

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/paginators/PaginatedOperationWithoutResultKeyPublisher.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ public class PaginatedOperationWithoutResultKeyPublisher implements SdkPublisher
7373

7474
private boolean isLastPage;
7575

76-
public PaginatedOperationWithoutResultKeyPublisher(final JsonProtocolTestsAsyncClient client,
77-
final PaginatedOperationWithoutResultKeyRequest firstRequest) {
76+
public PaginatedOperationWithoutResultKeyPublisher(JsonProtocolTestsAsyncClient client,
77+
PaginatedOperationWithoutResultKeyRequest firstRequest) {
7878
this(client, firstRequest, false);
7979
}
8080

81-
private PaginatedOperationWithoutResultKeyPublisher(final JsonProtocolTestsAsyncClient client,
82-
final PaginatedOperationWithoutResultKeyRequest firstRequest, final boolean isLastPage) {
81+
private PaginatedOperationWithoutResultKeyPublisher(JsonProtocolTestsAsyncClient client,
82+
PaginatedOperationWithoutResultKeyRequest firstRequest, boolean isLastPage) {
8383
this.client = client;
8484
this.firstRequest = firstRequest;
8585
this.isLastPage = isLastPage;
@@ -98,8 +98,8 @@ public void subscribe(Subscriber<? super PaginatedOperationWithoutResultKeyRespo
9898
* retrieve the consecutive pages that follows the input page.
9999
* </p>
100100
*/
101-
public final PaginatedOperationWithoutResultKeyPublisher resume(
102-
final PaginatedOperationWithoutResultKeyResponse lastSuccessfulPage) {
101+
private final PaginatedOperationWithoutResultKeyPublisher resume(
102+
PaginatedOperationWithoutResultKeyResponse lastSuccessfulPage) {
103103
if (nextPageFetcher.hasNextPage(lastSuccessfulPage)) {
104104
return new PaginatedOperationWithoutResultKeyPublisher(client, firstRequest.toBuilder()
105105
.nextToken(lastSuccessfulPage.nextToken()).build());

services/dynamodb/src/it/java/software/amazon/awssdk/services/dynamodb/ScanPaginatorIntegrationTest.java

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import static org.junit.Assert.assertEquals;
1919

2020
import java.util.HashMap;
21-
import java.util.Iterator;
2221
import java.util.Map;
2322
import java.util.Random;
2423
import java.util.stream.Stream;
@@ -185,44 +184,6 @@ public void mix_Iterator_And_Stream_Calls() {
185184
assertEquals(ITEM_COUNT, count);
186185
}
187186

188-
@Test
189-
public void test_resume_On_IntermediatePage() {
190-
ScanRequest request = ScanRequest.builder().tableName(TABLE_NAME).limit(5).build();
191-
ScanIterable scanResponses = dynamo.scanPaginator(request);
192-
193-
Iterator<ScanResponse> scanResponsesIterator = scanResponses.iterator();
194-
195-
int scannedCount = 0;
196-
scannedCount += scanResponsesIterator.next().count();
197-
198-
ScanResponse lastResponse = scanResponsesIterator.next();
199-
scannedCount += lastResponse.count();
200-
201-
// Resume from last page
202-
assertEquals(ITEM_COUNT, scannedCount + scanResponses.resume(lastResponse).stream()
203-
.flatMap(r -> r.items().stream())
204-
.count());
205-
206-
207-
assertEquals(ITEM_COUNT, scannedCount + scanResponses.resume(lastResponse).items().stream().count());
208-
}
209-
210-
211-
@Test
212-
public void test_resume_On_LastPage() {
213-
ScanRequest request = ScanRequest.builder().tableName(TABLE_NAME).limit(5).build();
214-
ScanIterable scanResponses = dynamo.scanPaginator(request);
215-
216-
ScanResponse lastPage = scanResponses.stream().reduce((first, second) -> second).get();
217-
218-
// Resume from last page
219-
assertEquals(0, scanResponses.resume(lastPage).stream()
220-
.flatMap(r -> r.items().stream())
221-
.count());
222-
223-
assertEquals(0, scanResponses.resume(lastPage).items().stream().count());
224-
}
225-
226187
private static void putTestData() {
227188
Map<String, AttributeValue> item = new HashMap();
228189
Random random = new Random();

services/s3/src/it/java/software/amazon/awssdk/services/s3/ListObjectsV2PaginatorsIntegrationTest.java

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -209,54 +209,6 @@ public void test_AsyncResponse_UsingRxJava() {
209209
assertThat(Long.valueOf(objectList.size()), equalTo(OBJECT_COUNT));
210210
}
211211

212-
@Test
213-
public void test_Resume_Using_IntermediatePage_OnAsyncResponse() throws ExecutionException, InterruptedException {
214-
ListObjectsV2Publisher publisher = s3Async.listObjectsV2Paginator(requestBuilder.bucket(bucketName).build());
215-
216-
TestSubscriber firstSubscriber = new TestSubscriber(2);
217-
publisher.subscribe(firstSubscriber);
218-
while (!firstSubscriber.isDone()) {
219-
Thread.sleep(1000);
220-
}
221-
222-
// Call resume
223-
ListObjectsV2Publisher resumedPublisher = publisher.resume(firstSubscriber.getLastPage());
224-
TestSubscriber secondSubscriber = new TestSubscriber(10);
225-
resumedPublisher.subscribe(secondSubscriber);
226-
while (!secondSubscriber.isDone()) {
227-
Thread.sleep(1000);
228-
}
229-
230-
assertThat(firstSubscriber.getKeyCount() + secondSubscriber.getKeyCount(),
231-
equalTo(OBJECT_COUNT));
232-
}
233-
234-
@Test
235-
public void test_Resume_Using_LastPage_OnAsyncResponse() throws ExecutionException, InterruptedException {
236-
ListObjectsV2Publisher publisher = s3Async.listObjectsV2Paginator(requestBuilder.bucket(bucketName).build());
237-
238-
final ListObjectsV2Response[] lastPage = new ListObjectsV2Response[1];
239-
CompletableFuture<Void> future = publisher.forEach(response -> {
240-
lastPage[0] = response;
241-
});
242-
future.get();
243-
244-
// Resume
245-
ListObjectsV2Publisher resumedPublisher = publisher.resume(lastPage[0]);
246-
247-
// count using pages
248-
final long[] count = {0};
249-
resumedPublisher.forEach(response -> count[0] += response.contents().size())
250-
.get();
251-
assertThat(count[0], equalTo(0L));
252-
253-
// count using items
254-
List<S3Object> objects = new ArrayList<>();
255-
resumedPublisher.contents().forEach(s3Object -> objects.add(s3Object))
256-
.get();
257-
assertThat(Long.valueOf(objects.size()), equalTo(0L));
258-
}
259-
260212
private class TestSubscriber implements Subscriber<ListObjectsV2Response> {
261213
private Subscription subscription;
262214
private ListObjectsV2Response lastPage;

0 commit comments

Comments
 (0)