timothyw553 commented on code in PR #19003:
URL: https://github.com/apache/iceberg/pull/19003#discussion_r4726951881


##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -2596,6 +2596,53 @@ public void testPaginationForListTables(int 
numberOfItems) {
             any());
   }
 
+  @Test
+  public void listNamespacesFailsOnRepeatedPageToken() {
+    RESTCatalogAdapter adapter = Mockito.spy(new 
RESTCatalogAdapter(backendCatalog));
+    RESTCatalog catalog = catalog(adapter);
+    Mockito.doReturn(
+            namespacesPage("a", Namespace.of("ns1")),
+            namespacesPage("b", Namespace.of("ns2")),
+            namespacesPage("a", Namespace.of("ns3")))

Review Comment:
   mockito repeats the last response if `checkPageToken` ever regresses, so 
this (and the table and view tests) would hang instead of failing. could we add 
a terminating fourth page with `null` so it fails right away?
   
   ```diff
                namespacesPage("b", Namespace.of("ns2")),
   -            namespacesPage("a", Namespace.of("ns3")))
   +            namespacesPage("a", Namespace.of("ns3")),
   +            namespacesPage(null, Namespace.of("ns4")))
   ```



##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -330,6 +341,7 @@ public List<TableIdentifier> listTables(SessionContext 
context, Namespace ns) {
     Map<String, String> queryParams = Maps.newHashMap();
     ImmutableList.Builder<TableIdentifier> tables = ImmutableList.builder();
     String pageToken = "";
+    Set<String> usedPageTokens = Sets.newHashSet(pageToken);

Review Comment:
   seeding `usedPageTokens` with `""` here (and in `listNamespaces` and 
`listViews`) makes an empty `next-page-token` fail immediately, which isn't 
covered by the `"a"`, `"b"`, `"a"` tests. could we add a test for each listing 
method with `""` followed by a `null` page, asserting `RESTException` after one 
request?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to