Skip to content

Commit f1552f6

Browse files
author
Giovanni Matteo Fumarola
committed
YARN-9553. Fix NPE in EntityGroupFSTimelineStore#getEntityTimelines. Contributed by Prabhu Joseph.
1 parent 30c6dd9 commit f1552f6

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/EntityGroupFSTimelineStore.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,11 @@ public TimelineEvents getEntityTimelines(String entityType,
11151115
LOG.debug("getEntityTimelines type={} ids={}", entityType, entityIds);
11161116
TimelineEvents returnEvents = new TimelineEvents();
11171117
List<EntityCacheItem> relatedCacheItems = new ArrayList<>();
1118+
1119+
if (entityIds == null || entityIds.isEmpty()) {
1120+
return returnEvents;
1121+
}
1122+
11181123
for (String entityId : entityIds) {
11191124
LOG.debug("getEntityTimeline type={} id={}", entityType, entityId);
11201125
List<TimelineStore> stores

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/test/java/org/apache/hadoop/yarn/server/timeline/TestEntityGroupFSTimelineStore.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.apache.hadoop.yarn.server.timeline.TimelineReader.Field;
4242
import org.apache.hadoop.yarn.util.ConverterUtils;
4343
import org.junit.After;
44+
import org.junit.Assert;
4445
import org.junit.AfterClass;
4546
import org.junit.Before;
4647
import org.junit.BeforeClass;
@@ -379,6 +380,16 @@ public void testCleanBuckets() throws Exception {
379380
assertFalse(fs.exists(clusterTimeStampDir1));
380381
}
381382

383+
@Test
384+
public void testNullCheckGetEntityTimelines() throws Exception {
385+
try {
386+
store.getEntityTimelines("YARN_APPLICATION", null, null, null, null,
387+
null);
388+
} catch (NullPointerException e) {
389+
Assert.fail("NPE when getEntityTimelines called with Null EntityIds");
390+
}
391+
}
392+
382393
@Test
383394
public void testPluginRead() throws Exception {
384395
// Verify precondition

0 commit comments

Comments
 (0)