This is an automated email from the ASF dual-hosted git repository.

sumitagrawal pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 660ccb9dab HDDS-9825. Fix ListKeys trailing prefix issue. (#5722)
660ccb9dab is described below

commit 660ccb9dab1b7f67241c307674e6fcc0f5962b3c
Author: ashishkumar50 <[email protected]>
AuthorDate: Thu Dec 7 11:34:43 2023 +0530

    HDDS-9825. Fix ListKeys trailing prefix issue. (#5722)
    
    Co-authored-by: ashishk <[email protected]>
---
 .../java/org/apache/hadoop/ozone/om/TestListKeysWithFSO.java | 12 ++++++++++++
 .../apache/hadoop/ozone/om/request/file/OMFileRequest.java   |  6 +++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestListKeysWithFSO.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestListKeysWithFSO.java
index d83bd48719..f5d6ed7529 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestListKeysWithFSO.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestListKeysWithFSO.java
@@ -267,6 +267,18 @@ public class TestListKeysWithFSO {
     checkKeyList("a1/b3/e3/e31.tx", "", expectedKeys, fsoOzoneBucket);
   }
 
+  @Test
+  public void testListKeysWithAndWithoutTrailingSlashInPrefix()
+      throws Exception {
+    List<String> expectedKeys = new ArrayList<>();
+    expectedKeys.add("a1/b2/d2/d21.tx");
+    // With trailing slash
+    checkKeyList("a1/b2/d2/d21.tx/", "", expectedKeys, fsoOzoneBucket);
+
+    //Without trailing slash
+    checkKeyList("a1/b2/d2/d21.tx", "", expectedKeys, fsoOzoneBucket);
+  }
+
   @Test
   public void testListKeysWithNonExistentStartKey() throws Exception {
     // case-1: StartKey LeafNode is lexographically ahead than prefixKey.
diff --git 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/file/OMFileRequest.java
 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/file/OMFileRequest.java
index 723bed9539..00c91c8fd9 100644
--- 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/file/OMFileRequest.java
+++ 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/file/OMFileRequest.java
@@ -58,6 +58,7 @@ import org.slf4j.LoggerFactory;
 
 import javax.annotation.Nonnull;
 
+import static org.apache.hadoop.hdds.scm.net.NetConstants.PATH_SEPARATOR_STR;
 import static org.apache.hadoop.ozone.om.OzoneManagerUtils.getBucketLayout;
 
 import static 
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.BUCKET_NOT_FOUND;
@@ -690,7 +691,10 @@ public final class OMFileRequest {
 
       if (omDirInfo != null) {
         lastKnownParentId = omDirInfo.getObjectID();
-      } else if (!elements.hasNext()) {
+      } else if (!elements.hasNext() && 
+          (!keyName.endsWith(PATH_SEPARATOR_STR))) {
+        // If the requested keyName contains "/" at the end then we need to
+        // just check the directory table.
         // reached last path component. Check file exists for the given path.
         OmKeyInfo omKeyInfo = OMFileRequest.getOmKeyInfoFromFileTable(false,
                 omMetadataMgr, dbNodeName, keyName);


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

Reply via email to