diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CommandWithDestination.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CommandWithDestination.java index 7152f02d3a6..65e52fd3b0b 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CommandWithDestination.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CommandWithDestination.java @@ -473,19 +473,20 @@ void writeStreamToFile(InputStream in, PathData target, FSDataOutputStream create(PathData item, boolean lazyPersist) throws IOException { try { - EnumSet createFlags = EnumSet.of(CREATE); if (lazyPersist) { - createFlags.add(LAZY_PERSIST); + EnumSet createFlags = EnumSet.of(CREATE, LAZY_PERSIST); + return create(item.path, + FsPermission.getFileDefault().applyUMask( + FsPermission.getUMask(getConf())), + createFlags, + getConf().getInt("io.file.buffer.size", 4096), + lazyPersist ? 1 : getDefaultReplication(item.path), + getDefaultBlockSize(), + null, + null); + } else { + return create(item.path, true); } - return create(item.path, - FsPermission.getFileDefault().applyUMask( - FsPermission.getUMask(getConf())), - createFlags, - getConf().getInt("io.file.buffer.size", 4096), - lazyPersist ? 1 : getDefaultReplication(item.path), - getDefaultBlockSize(), - null, - null); } finally { // might have been created but stream was interrupted deleteOnExit(item.path); }