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

ayushsaxena pushed a commit to branch branch-3.4
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.4 by this push:
     new 9a53df2c0bf HADOOP-19290. Operating on / in ChecksumFileSystem throws 
NPE. (#7074). Contributed by Ayush Saxena.
9a53df2c0bf is described below

commit 9a53df2c0bf9a9525ece4e799bc39431168062f8
Author: Ayush Saxena <ayushsax...@apache.org>
AuthorDate: Sat Sep 28 19:35:32 2024 +0530

    HADOOP-19290. Operating on / in ChecksumFileSystem throws NPE. (#7074). 
Contributed by Ayush Saxena.
---
 .../src/main/java/org/apache/hadoop/fs/ChecksumFileSystem.java     | 2 +-
 .../src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFileSystem.java
 
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFileSystem.java
index 716c6c50049..4171c8f13e2 100644
--- 
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFileSystem.java
+++ 
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFileSystem.java
@@ -770,7 +770,7 @@ public abstract class ChecksumFileSystem extends 
FilterFileSystem {
   abstract class FsOperation {
     boolean run(Path p) throws IOException {
       boolean status = apply(p);
-      if (status) {
+      if (status && !p.isRoot()) {
         Path checkFile = getChecksumFile(p);
         if (fs.exists(checkFile)) {
           apply(checkFile);
diff --git 
a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java
 
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java
index 4d611544908..8b42aa6779d 100644
--- 
a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java
+++ 
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java
@@ -300,4 +300,11 @@ public class TestChecksumFileSystem {
       assertEquals(perm, rawFs.getFileStatus(crc).getPermission());
     }
   }
+
+  @Test
+  public void testOperationOnRoot() throws Exception {
+    Path p = new Path("/");
+    localFs.mkdirs(p);
+    localFs.setReplication(p, 
localFs.getFileStatus(p).getPermission().toShort());
+  }
 }


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

Reply via email to