From e26be1d85c1f01b764f13a3c912446c935e620a5 Mon Sep 17 00:00:00 2001 From: Xuan Date: Wed, 5 Nov 2014 18:26:07 -0800 Subject: [PATCH] YARN-2813. Fixed NPE from MemoryTimelineStore.getDomains. Contributed by Zhijie Shen --- hadoop-yarn-project/CHANGES.txt | 2 ++ .../hadoop/yarn/server/timeline/MemoryTimelineStore.java | 4 ++++ .../hadoop/yarn/server/timeline/TimelineStoreTestUtils.java | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 63eb6f2e551..8c7882fd7e1 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -845,6 +845,8 @@ Release 2.6.0 - UNRELEASED FatalEventDispatcher try to transition RM to StandBy at the same time. (Rohith Sharmaks via jianhe) + YARN-2813. Fixed NPE from MemoryTimelineStore.getDomains. (Zhijie Shen via xgong) + Release 2.5.2 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/MemoryTimelineStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/MemoryTimelineStore.java index 2d126b48a01..af714b17b80 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/MemoryTimelineStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/MemoryTimelineStore.java @@ -241,6 +241,10 @@ public class MemoryTimelineStore public TimelineDomains getDomains(String owner) throws IOException { List domains = new ArrayList(); + Set domainsOfOneOwner = domainsByOwner.get(owner); + if (domainsOfOneOwner == null) { + return new TimelineDomains(); + } for (TimelineDomain domain : domainsByOwner.get(owner)) { TimelineDomain domainToReturn = createTimelineDomain( domain.getId(), diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/TimelineStoreTestUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/TimelineStoreTestUtils.java index 868838e61d9..242478cafa9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/TimelineStoreTestUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/TimelineStoreTestUtils.java @@ -946,6 +946,10 @@ public class TimelineStoreTestUtils { assertEquals(2, actualDomains.getDomains().size()); verifyDomainInfo(domain3, actualDomains.getDomains().get(0)); verifyDomainInfo(domain1, actualDomains.getDomains().get(1)); + + // owner without any domain + actualDomains = store.getDomains("owner_4"); + assertEquals(0, actualDomains.getDomains().size()); } private static void verifyDomainInfo(