diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index 5bdcac88d0..3bf3e34d9d 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -421,6 +421,7 @@ private static void populateLlapDaemonVarsSet(Set llapDaemonVarsSetLocal * 1) Hadoop configuration properties are applied. * 2) ConfVar properties with non-null values are overlayed. * 3) hive-site.xml properties are overlayed. + * 4) System Properties and Manual Overrides are overlayed. * * WARNING: think twice before adding any Hadoop configuration properties * with non-null values to this list as they will override any values defined @@ -5240,7 +5241,7 @@ private void initialize(Class cls) { addResource(hiveServer2SiteUrl); } - // Overlay the values of any system properties whose names appear in the list of ConfVars + // Overlay the values of any system properties and manual overrides applySystemProperties(); if ((this.get("hive.metastore.ds.retry.attempts") != null) || @@ -5507,7 +5508,9 @@ public ZoneId getLocalTimeZone() { }; - + //Take care of conf overrides. + //Includes values in ConfVars as well as underlying configuration properties (ie, hadoop) + public static Map overrides = new HashMap(); /** * Apply system properties to this object if the property name is defined in ConfVars @@ -5535,6 +5538,13 @@ private void applySystemProperties() { } } + for (Map.Entry oneVar : overrides.entrySet()) { + if (overrides.get(oneVar.getKey()) != null) { + if (overrides.get(oneVar.getKey()).length() > 0) { + systemProperties.put(oneVar.getKey(), oneVar.getValue()); + } + } + } return systemProperties; } diff --git a/service/src/java/org/apache/hive/service/server/HiveServer2.java b/service/src/java/org/apache/hive/service/server/HiveServer2.java index 1f6a097559..f1d2171482 100644 --- a/service/src/java/org/apache/hive/service/server/HiveServer2.java +++ b/service/src/java/org/apache/hive/service/server/HiveServer2.java @@ -1226,7 +1226,7 @@ ServerOptionsProcessorResponse parse(String[] argv) { + " or use the set the value in the configuration file" + " (see HIVE-19886)"); } - System.setProperty(propKey, confProps.getProperty(propKey)); + HiveConf.overrides.put(propKey, confProps.getProperty(propKey)); } // Process --help diff --git a/service/src/test/org/apache/hive/service/server/TestServerOptionsProcessor.java b/service/src/test/org/apache/hive/service/server/TestServerOptionsProcessor.java index d5e4ed6e25..652483aea9 100644 --- a/service/src/test/org/apache/hive/service/server/TestServerOptionsProcessor.java +++ b/service/src/test/org/apache/hive/service/server/TestServerOptionsProcessor.java @@ -18,6 +18,7 @@ package org.apache.hive.service.server; +import org.apache.hadoop.hive.conf.HiveConf; import org.junit.Assert; import org.junit.Test; @@ -39,14 +40,14 @@ public void test() { Assert.assertEquals( "checking system property before processing options", null, - System.getProperty(key)); + HiveConf.overrides.get(key)); optProcessor.parse(args); Assert.assertEquals( "checking system property after processing options", value, - System.getProperty(key)); + HiveConf.overrides.get(key)); } }