From 6a75c5af09fc1126a5406fec91da75011ca20c06 Mon Sep 17 00:00:00 2001 From: Karthik Kambatla Date: Wed, 24 Feb 2016 18:33:57 -0800 Subject: [PATCH] YARN-4729. SchedulerApplicationAttempt#getTotalRequiredResources can throw an NPE. (kasha) (cherry picked from commit c684f2b007a4808dafbe1c1d3ce01758e281d329) --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../resourcemanager/scheduler/SchedulerApplicationAttempt.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 89da4088f9c..ce2125bd745 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -166,6 +166,9 @@ Release 2.9.0 - UNRELEASED YARN-4651. Document movetoqueue option in 'YARN Commands' (Takashi Ohnishi via rohithsharmaks) + YARN-4729. SchedulerApplicationAttempt#getTotalRequiredResources can throw + an NPE. (kasha) + Release 2.8.0 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java index 0cbb88d0ef5..254200972cb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java @@ -244,7 +244,8 @@ public class SchedulerApplicationAttempt implements SchedulableEntity { } public synchronized int getTotalRequiredResources(Priority priority) { - return getResourceRequest(priority, ResourceRequest.ANY).getNumContainers(); + ResourceRequest request = getResourceRequest(priority, ResourceRequest.ANY); + return request == null ? 0 : request.getNumContainers(); } public synchronized Resource getResource(Priority priority) {