diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/EntityGroupFSTimelineStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/EntityGroupFSTimelineStore.java index e10eb1be88..8f00b852c0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/EntityGroupFSTimelineStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/EntityGroupFSTimelineStore.java @@ -376,7 +376,12 @@ int scanActiveLogs(Path dir) throws IOException { AppLogs logs = getAndSetActiveLog(appId, stat.getPath()); executor.execute(new ActiveLogParser(logs)); } else { - logsToScanCount += scanActiveLogs(stat.getPath()); + if (stat.isDirectory()) { + logsToScanCount += scanActiveLogs(stat.getPath()); + } else { + LOG.warn("Ignoring unexpected file in active directory {}", + stat.getPath()); + } } } return logsToScanCount; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/test/java/org/apache/hadoop/yarn/server/timeline/TestEntityGroupFSTimelineStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/test/java/org/apache/hadoop/yarn/server/timeline/TestEntityGroupFSTimelineStore.java index 8fcc696aad..984e157971 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/test/java/org/apache/hadoop/yarn/server/timeline/TestEntityGroupFSTimelineStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/test/java/org/apache/hadoop/yarn/server/timeline/TestEntityGroupFSTimelineStore.java @@ -510,6 +510,23 @@ public void testGetEntityPluginRead() throws Exception { } } + @Test + public void testScanActiveLogsWithInvalidFile() throws Exception { + Path invalidFile = new Path(testActiveDirPath, "invalidfile"); + try { + if (!fs.exists(invalidFile)) { + fs.createNewFile(invalidFile); + } + store.scanActiveLogs(); + } catch (StackOverflowError error) { + Assert.fail("EntityLogScanner crashed with StackOverflowError"); + } finally { + if (fs.exists(invalidFile)) { + fs.delete(invalidFile, false); + } + } + } + @Test public void testScanActiveLogsAndMoveToDonePluginRead() throws Exception { EntityGroupFSTimelineStore store = null;