soarez commented on code in PR #14899:
URL: https://github.com/apache/kafka/pull/14899#discussion_r1413167592


##########
shell/src/main/java/org/apache/kafka/shell/MetadataShell.java:
##########
@@ -81,6 +85,55 @@ public MetadataShell build() {
         }
     }
 
+    /**
+     * Return the grandparent directory of a file. This works around Java's 
quirky API,
+     * which does not honor the UNIX convention of the parent of root being 
root itself.
+     */
+    static File parentParent(File file) {
+        File parent = file.getParentFile();
+        if (parent == null) {
+            return file;
+        }
+        File parentParent = parent.getParentFile();
+        if (parentParent == null) {
+            return parent;
+        }
+        return parentParent;
+    }

Review Comment:
   ```suggestion
       /**
        * Return the parent directory of a file. This works around Java's 
quirky API,
        * which does not honor the UNIX convention of the parent of root being 
root itself.
        */
       static File parent(File file) {
           File parent = file.getParentFile();
           return parent == null ? file : parent;
       }
       
       static File parentParent(File file) {
           return parent(parent(file));
       }
   ```



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to