elek commented on a change in pull request #1451:
URL: https://github.com/apache/hadoop-ozone/pull/1451#discussion_r499525922



##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
##########
@@ -919,12 +920,32 @@ private boolean isKeyEmpty(OmKeyInfo keyInfo) {
     // underlying table using an iterator. That automatically creates a
     // snapshot of the data, so we don't need these locks at a higher level
     // when we iterate.
+
+    startKey = normalizeListKeyPath(startKey);
+    keyPrefix = normalizeListKeyPath(keyPrefix);

Review comment:
       NIT:
   
   I think it's easier to follow to move the condition to here:
   
   ```
        if (enableFileSystemPaths) {
          startKey = normalizeListKeyPath(startKey);
          keyPrefix = normalizeListKeyPath(keyPrefix);
       }
   ```
   
   Despite the name, the `startKey` and `keyPrefix` are not normalized if 
`enableFileSystemPaths` is false

##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/OMClientRequest.java
##########
@@ -298,21 +296,11 @@ public static String validateAndNormalizeKey(boolean 
enableFileSystemPaths,
     }
   }
 
-  @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
+
   public static String validateAndNormalizeKey(String keyName)
       throws OMException {
-    String normalizedKeyName;
-    if (keyName.startsWith(OM_KEY_PREFIX)) {
-      normalizedKeyName = Paths.get(keyName).toUri().normalize().getPath();
-    } else {
-      normalizedKeyName = Paths.get(OM_KEY_PREFIX, keyName).toUri()
-          .normalize().getPath();
-    }
-    if (!keyName.equals(normalizedKeyName)) {
-      LOG.debug("Normalized key {} to {} ", keyName,
-          normalizedKeyName.substring(1));
-    }
-    return isValidKeyPath(normalizedKeyName.substring(1));
+    String normalizedKeyName = OmUtils.normalizeKey(keyName);
+    return isValidKeyPath(normalizedKeyName);

Review comment:
       Do we need this method at all? Is it possible to have invalid key path 
after `OmUtils.normalizeKey`? Seems to be an unnecessary additional step.

##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
##########
@@ -919,12 +920,32 @@ private boolean isKeyEmpty(OmKeyInfo keyInfo) {
     // underlying table using an iterator. That automatically creates a
     // snapshot of the data, so we don't need these locks at a higher level
     // when we iterate.
+
+    startKey = normalizeListKeyPath(startKey);
+    keyPrefix = normalizeListKeyPath(keyPrefix);
+
     List<OmKeyInfo> keyList = metadataManager.listKeys(volumeName, bucketName,
         startKey, keyPrefix, maxKeys);
     refreshPipeline(keyList);
     return keyList;
   }
 
+  private String normalizeListKeyPath(String keyPath) {
+
+    String normalizeKeyPath = keyPath;
+    if (enableFileSystemPaths) {
+      // For empty strings do nothing.
+      if (StringUtils.isBlank(keyPath)) {

Review comment:
       Is there any reason to keep these two features (return empty string for 
empty string + keep closing `/`) in here intead of moving to  
`OmUtils.normalizeKey(keyPath)`




----------------------------------------------------------------
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.

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



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

Reply via email to