elphastori commented on code in PR #13129:
URL: https://github.com/apache/iceberg/pull/13129#discussion_r2117784169


##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -565,13 +568,16 @@ public List<Namespace> listNamespaces(SessionContext 
context, Namespace namespac
     }
 
     ImmutableList.Builder<Namespace> namespaces = ImmutableList.builder();
-    String pageToken = "";
+    String pageToken = null;
     if (pageSize != null) {
       queryParams.put("pageSize", String.valueOf(pageSize));
     }
 
     do {
-      queryParams.put("pageToken", pageToken);
+      if (pageToken != null) {
+        queryParams.put("pageToken", pageToken);
+      }
+

Review Comment:
   @kevinjqliu I agree, your suggestion seems to be the more natural use of a 
`do...while` loop.
   
   At this point, we could even remove the null check because no further 
iteration will been run if pageToken is `null`.
   
   Let me run some tests and push the change.
   
   ```
       String pageToken = null;
       if (pageSize != null) {
         queryParams.put("pageSize", String.valueOf(pageSize));
       }
   
       do {
         AuthSession contextualSession = authManager.contextualSession(context, 
catalogAuth);
         ListNamespacesResponse response =
             client
                 .withAuthSession(contextualSession)
                 .get(
                     paths.namespaces(),
                     queryParams,
                     ListNamespacesResponse.class,
                     Map.of(),
                     ErrorHandlers.namespaceErrorHandler());
         pageToken = response.nextPageToken();
         queryParams.put("pageToken", pageToken);
         namespaces.addAll(response.namespaces());
       } while (pageToken != null);
   
       return namespaces.build();
     }
     ```



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to