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 586350d843997..c9ccc09235ff5 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 FSDataOutputStream createNonRecursive(final Path f, 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 4d61154490838..8b42aa6779dad 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 void testSetPermissionCrc() throws Exception { 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()); + } }