From 0d94a293a8baa4f4eaeb7015b6e23de2286a20e2 Mon Sep 17 00:00:00 2001 From: cnauroth Date: Wed, 1 Jul 2015 19:47:58 -0700 Subject: [PATCH] HADOOP-12172. FsShell mkdir -p makes an unnecessary check for the existence of the parent. Contributed by Chris Nauroth. (cherry picked from commit f3796224bfdfd88e2428cc8a9915bdfdc62b48f3) --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../src/main/java/org/apache/hadoop/fs/shell/Mkdir.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 9d7398a16be..6bf3600755e 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -201,6 +201,9 @@ Release 2.8.0 - UNRELEASED HADOOP-12112. Make hadoop-common-project Native code -Wall-clean (alanburlison via cmccabe) + HADOOP-12172. FsShell mkdir -p makes an unnecessary check for the existence + of the parent. (cnauroth) + BUG FIXES HADOOP-11802: DomainSocketWatcher thread terminates sometimes after there diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java index 74bad627596..9f39da29ce2 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java @@ -70,7 +70,8 @@ class Mkdir extends FsCommand { protected void processNonexistentPath(PathData item) throws IOException { // check if parent exists. this is complicated because getParent(a/b/c/) returns a/b/c, but // we want a/b - if (!item.fs.exists(new Path(item.path.toString()).getParent()) && !createParents) { + if (!createParents && + !item.fs.exists(new Path(item.path.toString()).getParent())) { throw new PathNotFoundException(item.toString()); } if (!item.fs.mkdirs(item.path)) {