diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java index 2731cb4fe6ab2..63b5bc7d94ac3 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java @@ -1643,7 +1643,7 @@ public MultipartUploaderBuilder createMultipartUploader(Path basePath) * The enclosing root path is a common ancestor that should be used for temp and staging dirs * as well as within encryption zones and other restricted directories. * - * Call makeQualified on the param path to ensure the param path to ensure its part of the correct filesystem + * Call makeQualified on the param path to ensure its part of the correct filesystem * * @param path file path to find the enclosing root path for * @return a path to the enclosing root diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java index 8be2daea74ebd..0213772ab6a5c 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java @@ -4949,7 +4949,7 @@ public CompletableFuture build() throws IOException { * The enclosing root path is a common ancestor that should be used for temp and staging dirs * as well as within encryption zones and other restricted directories. * - * Call makeQualified on the param path to ensure the param path to ensure its part of the correct filesystem. + * Call makeQualified on the param path to ensure its part of the correct filesystem. * * @param path file path to find the enclosing root path for * @return a path to the enclosing root diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java index 9185843be81c5..71078cb5345b6 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java @@ -1940,7 +1940,8 @@ public Path getEnclosingRoot(Path path) throws IOException { try { res = fsState.resolve((path.toString()), true); } catch (FileNotFoundException ex) { - throw new NotInMountpointException(path, String.format("getEnclosingRoot - %s", ex.getMessage())); + throw new NotInMountpointException(path, + String.format("getEnclosingRoot - %s", ex.getMessage())); } Path fullPath = new Path(res.resolvedPath); Path enclosingPath = res.targetFileSystem.getEnclosingRoot(path); diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java index 06f3e3aed1a8d..74e12de46fb37 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java @@ -1484,7 +1484,8 @@ public Path getEnclosingRoot(Path path) throws IOException { try { res = fsState.resolve((path.toString()), true); } catch (FileNotFoundException ex) { - throw new NotInMountpointException(path, String.format("getEnclosingRoot - %s", ex.getMessage())); + throw new NotInMountpointException(path, + String.format("getEnclosingRoot - %s", ex.getMessage())); } Path fullPath = new Path(res.resolvedPath); Path enclosingPath = res.targetFileSystem.getEnclosingRoot(path); diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractGetEnclosingRoot.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractGetEnclosingRoot.java index 597cc19ece686..068a400817d17 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractGetEnclosingRoot.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractGetEnclosingRoot.java @@ -40,13 +40,18 @@ public void testEnclosingRootEquivalence() throws IOException { root, fs.getEnclosingRoot(foobar)); assertEquals("Ensure getEnclosingRoot called on itself returns the root directory", root, fs.getEnclosingRoot(fs.getEnclosingRoot(foobar))); - assertEquals("Ensure getEnclosingRoot for different paths in the same enclosing root returns the same path", + assertEquals( + "Ensure getEnclosingRoot for different paths in the same enclosing root returns the same path", fs.getEnclosingRoot(root), fs.getEnclosingRoot(foobar)); assertEquals("Ensure getEnclosingRoot on a path returns the root directory", root, fs.getEnclosingRoot(methodPath())); assertEquals("Ensure getEnclosingRoot called on itself on a path returns the root directory", root, fs.getEnclosingRoot(fs.getEnclosingRoot(methodPath()))); - assertEquals("Ensure getEnclosingRoot for different paths in the same enclosing root returns the same path", fs.getEnclosingRoot(root), fs.getEnclosingRoot(methodPath())); + assertEquals( + "Ensure getEnclosingRoot for different paths in the same enclosing root " + + "returns the same path", + fs.getEnclosingRoot(root), + fs.getEnclosingRoot(methodPath())); } @@ -57,7 +62,8 @@ public void testEnclosingRootPathExists() throws Exception { Path foobar = methodPath(); fs.mkdirs(foobar); - assertEquals("Ensure getEnclosingRoot returns the root directory when the root directory exists", + assertEquals( + "Ensure getEnclosingRoot returns the root directory when the root directory exists", root, fs.getEnclosingRoot(foobar)); assertEquals("Ensure getEnclosingRoot returns the root directory when the directory exists", root, fs.getEnclosingRoot(foobar)); @@ -70,9 +76,11 @@ public void testEnclosingRootPathDNE() throws Exception { Path root = path("/"); // . - assertEquals("Ensure getEnclosingRoot returns the root directory even when the path does not exist", + assertEquals( + "Ensure getEnclosingRoot returns the root directory even when the path does not exist", root, fs.getEnclosingRoot(foobar)); - assertEquals("Ensure getEnclosingRoot returns the root directory even when the path does not exist", + assertEquals( + "Ensure getEnclosingRoot returns the root directory even when the path does not exist", root, fs.getEnclosingRoot(methodPath())); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java index 526048907a382..afa6ccaf2dad4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java @@ -193,34 +193,34 @@ Path getTrashRootInFallBackFS() throws IOException { @Test public void testTrashRootsAfterEncryptionZoneDeletion() throws Exception { try { - final Path zone = new Path("/EZ"); - fsTarget.mkdirs(zone); - final Path zone1 = new Path("/EZ/zone1"); - fsTarget.mkdirs(zone1); - - DFSTestUtil.createKey("test_key", cluster, CONF); - HdfsAdmin hdfsAdmin = new HdfsAdmin(cluster.getURI(0), CONF); - final EnumSet provisionTrash = - EnumSet.of(CreateEncryptionZoneFlag.PROVISION_TRASH); - hdfsAdmin.createEncryptionZone(zone1, "test_key", provisionTrash); - - final Path encFile = new Path(zone1, "encFile"); - DFSTestUtil.createFile(fsTarget, encFile, 10240, (short) 1, 0xFEED); - - Configuration clientConf = new Configuration(CONF); - clientConf.setLong(FS_TRASH_INTERVAL_KEY, 1); - clientConf.set("fs.default.name", fsTarget.getUri().toString()); - FsShell shell = new FsShell(clientConf); - - //Verify file deletion within EZ - DFSTestUtil.verifyDelete(shell, fsTarget, encFile, true); - assertTrue("ViewFileSystem trash roots should include EZ file trash", - (fsView.getTrashRoots(true).size() == 1)); - - //Verify deletion of EZ - DFSTestUtil.verifyDelete(shell, fsTarget, zone, true); - assertTrue("ViewFileSystem trash roots should include EZ zone trash", - (fsView.getTrashRoots(true).size() == 2)); + final Path zone = new Path("/EZ"); + fsTarget.mkdirs(zone); + final Path zone1 = new Path("/EZ/zone1"); + fsTarget.mkdirs(zone1); + + DFSTestUtil.createKey("test_key", cluster, CONF); + HdfsAdmin hdfsAdmin = new HdfsAdmin(cluster.getURI(0), CONF); + final EnumSet provisionTrash = + EnumSet.of(CreateEncryptionZoneFlag.PROVISION_TRASH); + hdfsAdmin.createEncryptionZone(zone1, "test_key", provisionTrash); + + final Path encFile = new Path(zone1, "encFile"); + DFSTestUtil.createFile(fsTarget, encFile, 10240, (short) 1, 0xFEED); + + Configuration clientConf = new Configuration(CONF); + clientConf.setLong(FS_TRASH_INTERVAL_KEY, 1); + clientConf.set("fs.default.name", fsTarget.getUri().toString()); + FsShell shell = new FsShell(clientConf); + + //Verify file deletion within EZ + DFSTestUtil.verifyDelete(shell, fsTarget, encFile, true); + assertTrue("ViewFileSystem trash roots should include EZ file trash", + (fsView.getTrashRoots(true).size() == 1)); + + //Verify deletion of EZ + DFSTestUtil.verifyDelete(shell, fsTarget, zone, true); + assertTrue("ViewFileSystem trash roots should include EZ zone trash", + (fsView.getTrashRoots(true).size() == 2)); } finally { DFSTestUtil.deleteKey("test_key", cluster); }