From c684f2b007a4808dafbe1c1d3ce01758e281d329 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) --- 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 732719232b..7f26f8e63c 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -227,6 +227,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 0cbb88d0ef..254200972c 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 synchronized ResourceRequest getResourceRequest(Priority priority, } 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) {