From 5c8d90763c52f6bf5224b59738739bd2d1a4b4b8 Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Fri, 28 Sep 2018 10:02:56 +0900 Subject: [PATCH] HADOOP-15764. Addendum patch: Fix NPE in SecurityUtil. --- .../java/org/apache/hadoop/security/SecurityUtil.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java index 9fea535ec0..2313119bfe 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java @@ -586,12 +586,14 @@ public InetAddress getByName(String host) throws UnknownHostException { * hadoop.security.token.service.use_ip=false */ protected static class QualifiedHostResolver implements HostResolver { - private List searchDomains; + private List searchDomains = new ArrayList<>(); { ResolverConfig resolverConfig = ResolverConfig.getCurrentConfig(); - searchDomains = new ArrayList<>(); - for (Name name : resolverConfig.searchPath()) { - searchDomains.add(name.toString()); + Name[] names = resolverConfig.searchPath(); + if (names != null) { + for (Name name : names) { + searchDomains.add(name.toString()); + } } }