From 1c594639f1c1fbd96ca610107f2736305d3ebfb5 Mon Sep 17 00:00:00 2001 From: Rushabh Shah Date: Mon, 21 May 2018 12:33:00 -0500 Subject: [PATCH] Skip the proxy user check if the ugi has not been initialized. Contributed by Daryn Sharp (cherry picked from commit 73e9120ad79c73703de21e0084591861813f3279) --- .../main/java/org/apache/hadoop/conf/Configuration.java | 2 +- .../org/apache/hadoop/security/UserGroupInformation.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java index a69e4c406bc..bd6277f16eb 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java @@ -281,7 +281,7 @@ public class Configuration implements Iterable>, } private static boolean getRestrictParserDefault(Object resource) { - if (resource instanceof String) { + if (resource instanceof String || !UserGroupInformation.isInitialized()) { return false; } UserGroupInformation user; diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java index d0522a06f77..99617f8a4ee 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java @@ -287,14 +287,18 @@ public class UserGroupInformation { public static final String HADOOP_TOKEN_FILE_LOCATION = "HADOOP_TOKEN_FILE_LOCATION"; + public static boolean isInitialized() { + return conf != null; + } + /** * A method to initialize the fields that depend on a configuration. * Must be called before useKerberos or groups is used. */ private static void ensureInitialized() { - if (conf == null) { + if (!isInitialized()) { synchronized(UserGroupInformation.class) { - if (conf == null) { // someone might have beat us + if (!isInitialized()) { // someone might have beat us initialize(new Configuration(), false); } }