diff --git a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/mapred/CopyMapper.java b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/mapred/CopyMapper.java index 6f88660651f..a979a29b33d 100644 --- a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/mapred/CopyMapper.java +++ b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/mapred/CopyMapper.java @@ -245,7 +245,7 @@ public class CopyMapper extends Mapper return; } - FileAction action = checkUpdate(sourceFS, sourceCurrStatus, target); + FileAction action = checkUpdate(sourceFS, sourceCurrStatus, target, targetStatus); if (action == FileAction.SKIP) { LOG.info("Skipping copy of " + sourceCurrStatus.getPath() + " to " + target); @@ -332,13 +332,7 @@ public class CopyMapper extends Mapper } private FileAction checkUpdate(FileSystem sourceFS, FileStatus source, - Path target) throws IOException { - final FileStatus targetFileStatus; - try { - targetFileStatus = targetFS.getFileStatus(target); - } catch (FileNotFoundException e) { - return FileAction.OVERWRITE; - } + Path target, FileStatus targetFileStatus) throws IOException { if (targetFileStatus != null && !overWrite) { if (canSkip(sourceFS, source, targetFileStatus)) { return FileAction.SKIP;