From 647a35e996d33d8df898891760305222446b68f5 Mon Sep 17 00:00:00 2001 From: Zhe Zhang Date: Tue, 23 Feb 2016 13:29:39 -0800 Subject: [PATCH] HDFS-9844. Correct path creation in getTrashRoot to handle root dir. Change-Id: I5afe6c7176063892e3e632698c849bd9f4b92906 --- .../apache/hadoop/hdfs/DistributedFileSystem.java | 2 +- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../apache/hadoop/hdfs/TestEncryptionZones.java | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java index 69f38715bf..d6eb9e5c73 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java @@ -2355,7 +2355,7 @@ public Path getTrashRoot(Path path) { EncryptionZone ez = dfs.getEZForPath(parentSrc); if ((ez != null)) { return this.makeQualified( - new Path(ez.getPath() + "/" + FileSystem.TRASH_PREFIX + + new Path(ez.getPath(), FileSystem.TRASH_PREFIX + dfs.ugi.getShortUserName())); } } catch (IOException e) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 526ddff8b5..83eacc35e4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1954,6 +1954,8 @@ Release 2.8.0 - UNRELEASED HDFS-9084. Pagination, sorting and filtering of files/directories in the HDFS Web UI. (Ravi Prakash via ozawa) + HDFS-9844. Correct path creation in getTrashRoot to handle root dir. (zhz) + OPTIMIZATIONS HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java index 42cb6612af..82a646f489 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java @@ -1428,6 +1428,20 @@ public void testEncryptionZoneWithTrash() throws Exception { verifyShellDeleteWithTrash(shell, topEZ); } + @Test(timeout = 120000) + public void testRootDirEZTrash() throws Exception { + final HdfsAdmin dfsAdmin = + new HdfsAdmin(FileSystem.getDefaultUri(conf), conf); + dfsAdmin.createEncryptionZone(new Path("/"), TEST_KEY); + final Path encFile = new Path("/encFile"); + final int len = 8192; + DFSTestUtil.createFile(fs, encFile, len, (short) 1, 0xFEED); + Configuration clientConf = new Configuration(conf); + clientConf.setLong(FS_TRASH_INTERVAL_KEY, 1); + FsShell shell = new FsShell(clientConf); + verifyShellDeleteWithTrash(shell, encFile); + } + private void verifyShellDeleteWithTrash(FsShell shell, Path path) throws Exception{ try {