From 2044967e7581f00c3f6378860426a69078faf694 Mon Sep 17 00:00:00 2001 From: Suma Shivaprasad Date: Tue, 5 Feb 2019 09:39:38 -0800 Subject: [PATCH] YARN-9246 NPE when executing a command yarn node -status or -states without additional arguments. Contributed by Masahiro Tanaka --- .../java/org/apache/hadoop/yarn/client/cli/YarnCLI.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/YarnCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/YarnCLI.java index 0747b63773..c1e02d5fd1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/YarnCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/YarnCLI.java @@ -72,6 +72,10 @@ public void setClient(YarnClient client) { } public void stop() { - this.client.stop(); + // this.client may be null when it is called before + // invoking `createAndStartYarnClient` + if (this.client != null) { + this.client.stop(); + } } } \ No newline at end of file