From a596c6f5eb553cf38123d61b844696ddbec99be0 Mon Sep 17 00:00:00 2001 From: Wei-Chiu Chuang Date: Mon, 16 Oct 2017 12:57:48 -0700 Subject: [PATCH] HDFS-12485. expunge may fail to remove trash from encryption zone. Contributed by Wei-Chiu Chuang. (cherry picked from commit 8dbc8909c92d502d10a7f94d1de3171878a43b04) --- .../java/org/apache/hadoop/hdfs/DistributedFileSystem.java | 3 +-- .../apache/hadoop/hdfs/TestTrashWithSecureEncryptionZones.java | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) 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 55c9f6fddb6..e33858a2832 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 @@ -2621,8 +2621,7 @@ public Collection getTrashRoots(boolean allUsers) { } } } else { - Path userTrash = new Path(ezTrashRoot, System.getProperty( - "user.name")); + Path userTrash = new Path(ezTrashRoot, dfs.ugi.getShortUserName()); try { ret.add(getFileStatus(userTrash)); } catch (FileNotFoundException ignored) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithSecureEncryptionZones.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithSecureEncryptionZones.java index 314adfb7a56..a8e2a7114ab 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithSecureEncryptionZones.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithSecureEncryptionZones.java @@ -225,7 +225,6 @@ public static void init() throws Exception { clientConf = new Configuration(conf); clientConf.setLong(FS_TRASH_INTERVAL_KEY, 1); shell = new FsShell(clientConf); - System.setProperty("user.name", HDFS_USER_NAME); } @AfterClass