anmolanmol1234 commented on code in PR #7698:
URL: https://github.com/apache/hadoop/pull/7698#discussion_r2099461766


##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java:
##########
@@ -2053,26 +2033,15 @@ public boolean isNonEmptyDirectory(String path,
       TracingContext tracingContext) throws AzureBlobFileSystemException {
     // This method is only called internally to determine state of a path
     // and hence don't need identity transformation to happen.
-    ListResponseData listResponseData = listPath(path, false, 1, null, 
tracingContext, null, false);
-    return !isEmptyListResults(listResponseData);
-  }
-
-  /**
-   * Check if the list call returned empty results without any continuation 
token.
-   * @param listResponseData The response of listing API from the server.
-   * @return True if empty results without continuation token.
-   */
-  private boolean isEmptyListResults(ListResponseData listResponseData) {
-    AbfsHttpOperation result = listResponseData.getOp().getResult();
-    boolean isEmptyList = result != null && result.getStatusCode() == HTTP_OK 
&& // List Call was successful
-        result.getListResultSchema() != null && // Parsing of list response 
was successful
-        listResponseData.getFileStatusList().isEmpty() && 
listResponseData.getRenamePendingJsonPaths().isEmpty() &&// No paths were 
returned
-        StringUtils.isEmpty(listResponseData.getContinuationToken()); // No 
continuation token was returned
-    if (isEmptyList) {
-      LOG.debug("List call returned empty results without any continuation 
token.");
-      return true;
-    }
-    return false;
+    String continuationToken = null;
+    List<FileStatus> fileStatusList = new ArrayList<>();
+    // We need to loop on continuation token until we get an entry or 
continuation token becomes null.
+    do {
+      ListResponseData listResponseData = listPath(path, false, 1, null, 
tracingContext, null);
+      fileStatusList.addAll(listResponseData.getFileStatusList());

Review Comment:
     continuationToken = listResponseData.getContinuationToken();
       if (StringUtils.isNotEmpty(continuationToken) && fileStatusList != null 
&& !fileStatusList.isEmpty()) {
         return true;
       }
     } while (StringUtils.isNotEmpty(continuationToken));
   
    we should just return true from here as soon as we receive one entry in the 
list right ?



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

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


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

Reply via email to