diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java index e5cb2553a8..d806b121e0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java @@ -310,12 +310,17 @@ public String getUser() { } private Set getPendingLogFilesToUpload(File containerLogDir) { - if(containerLogDir == null || - containerLogDir.listFiles() == null) { + if(containerLogDir == null) { return new HashSet<>(0); } + + File[] filesList = containerLogDir.listFiles(); + if (filesList == null) { + return new HashSet<>(0); + } + Set candidates = - new HashSet(Arrays.asList(containerLogDir.listFiles())); + new HashSet(Arrays.asList(filesList)); for (File logFile : candidates) { this.allExistingFileMeta.add(getLogFileMetaData(logFile)); }