This is an automated email from the ASF dual-hosted git repository.

gifuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new f1552f6  YARN-9553. Fix NPE in 
EntityGroupFSTimelineStore#getEntityTimelines. Contributed by Prabhu Joseph.
f1552f6 is described below

commit f1552f6edb8fe152003fd71944851b2b46a6677d
Author: Giovanni Matteo Fumarola <[email protected]>
AuthorDate: Thu May 30 11:42:27 2019 -0700

    YARN-9553. Fix NPE in EntityGroupFSTimelineStore#getEntityTimelines. 
Contributed by Prabhu Joseph.
---
 .../yarn/server/timeline/EntityGroupFSTimelineStore.java      |  5 +++++
 .../yarn/server/timeline/TestEntityGroupFSTimelineStore.java  | 11 +++++++++++
 2 files changed, 16 insertions(+)

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 498230a..a5e5b41 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
@@ -1115,6 +1115,11 @@ public class EntityGroupFSTimelineStore extends 
CompositeService
     LOG.debug("getEntityTimelines type={} ids={}", entityType, entityIds);
     TimelineEvents returnEvents = new TimelineEvents();
     List<EntityCacheItem> relatedCacheItems = new ArrayList<>();
+
+    if (entityIds == null || entityIds.isEmpty()) {
+      return returnEvents;
+    }
+
     for (String entityId : entityIds) {
       LOG.debug("getEntityTimeline type={} id={}", entityType, entityId);
       List<TimelineStore> stores
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 dc10912..8fcc696 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
@@ -41,6 +41,7 @@ import 
org.apache.hadoop.yarn.server.timeline.EntityGroupFSTimelineStore.AppStat
 import org.apache.hadoop.yarn.server.timeline.TimelineReader.Field;
 import org.apache.hadoop.yarn.util.ConverterUtils;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -380,6 +381,16 @@ public class TestEntityGroupFSTimelineStore extends 
TimelineStoreTestUtils {
   }
 
   @Test
+  public void testNullCheckGetEntityTimelines() throws Exception {
+    try {
+      store.getEntityTimelines("YARN_APPLICATION", null, null, null, null,
+          null);
+    } catch (NullPointerException e) {
+      Assert.fail("NPE when getEntityTimelines called with Null EntityIds");
+    }
+  }
+
+  @Test
   public void testPluginRead() throws Exception {
     // Verify precondition
     assertEquals(EntityGroupPlugInForTest.class.getName(),


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to