From 9dc180d14a265b49bdfb5f6a4cbdf476661e6b2d Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Thu, 20 Sep 2018 13:05:46 +0100 Subject: [PATCH] HADOOP-15748. S3 listing inconsistency can raise NPE in globber. Contributed by Steve Loughran. (cherry picked from commit 646874c326139457b79cf8cfa547b3c91a78c7b4) --- .../src/main/java/org/apache/hadoop/fs/Globber.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java index ca3db1d98eb..b241a949b15 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java @@ -245,7 +245,18 @@ class Globber { // incorrectly conclude that /a/b was a file and should not match // /a/*/*. So we use getFileStatus of the path we just listed to // disambiguate. - if (!getFileStatus(candidate.getPath()).isDirectory()) { + Path path = candidate.getPath(); + FileStatus status = getFileStatus(path); + if (status == null) { + // null means the file was not found + LOG.warn("File/directory {} not found:" + + " it may have been deleted." + + " If this is an object store, this can be a sign of" + + " eventual consistency problems.", + path); + continue; + } + if (!status.isDirectory()) { continue; } }