diff --git common/src/java/org/apache/hadoop/hive/common/ValidTxnListImpl.java common/src/java/org/apache/hadoop/hive/common/ValidTxnListImpl.java index 0a0e5d0..09b6750 100644 --- common/src/java/org/apache/hadoop/hive/common/ValidTxnListImpl.java +++ common/src/java/org/apache/hadoop/hive/common/ValidTxnListImpl.java @@ -30,10 +30,10 @@ public class ValidTxnListImpl implements ValidTxnList { - static final private Log LOG = LogFactory.getLog(ValidTxnListImpl.class.getName()); - final static private int MAX_UNCOMPRESSED_LENGTH = 256; - final static private char COMPRESSION_MARKER = 'C'; - final static private String STRING_ENCODING = "ISO-8859-1"; + private static final Log LOG = LogFactory.getLog(ValidTxnListImpl.class.getName()); + private static final int MAX_UNCOMPRESSED_LENGTH = 256; + private static final char COMPRESSION_MARKER = 'C'; + private static final String STRING_ENCODING = "ISO-8859-1"; private long[] exceptions; private long highWatermark; diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/ScriptOperator.java ql/src/java/org/apache/hadoop/hive/ql/exec/ScriptOperator.java index 87eaa8f..de50514 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/ScriptOperator.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/ScriptOperator.java @@ -27,6 +27,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.Map; @@ -143,17 +144,19 @@ String safeEnvVarValue(String value, String name, boolean truncate) { return value; } - boolean blackListed(String name) { + /** + * Checks whether a given configuration name is blacklisted and should not be converted + * to an environment variable. + */ + boolean blackListed(Configuration conf, String name) { if (blackListedConfEntries == null) { blackListedConfEntries = new HashSet(); - if (hconf != null) { - String bl = hconf.get(HiveConf.ConfVars.HIVESCRIPT_ENV_BLACKLIST.toString()); - if (bl != null && bl.length() > 0) { + if (conf != null) { + String bl = conf.get(HiveConf.ConfVars.HIVESCRIPT_ENV_BLACKLIST.toString(), + HiveConf.ConfVars.HIVESCRIPT_ENV_BLACKLIST.getDefaultValue()); + if (bl != null && !bl.isEmpty()) { String[] bls = bl.split(","); - for (String b : bls) { - b.replaceAll(".", "_"); - blackListedConfEntries.add(b); - } + Collections.addAll(blackListedConfEntries, bls); } } } @@ -169,7 +172,7 @@ void addJobConfToEnvironment(Configuration conf, Map env) { while (it.hasNext()) { Map.Entry en = it.next(); String name = en.getKey(); - if (!blackListed(name)) { + if (!blackListed(conf, name)) { // String value = (String)en.getValue(); // does not apply variable // expansion String value = conf.get(name); // does variable expansion diff --git ql/src/test/org/apache/hadoop/hive/ql/exec/TestOperators.java ql/src/test/org/apache/hadoop/hive/ql/exec/TestOperators.java index 9359a7a..e4c5300 100644 --- ql/src/test/org/apache/hadoop/hive/ql/exec/TestOperators.java +++ ql/src/test/org/apache/hadoop/hive/ql/exec/TestOperators.java @@ -57,6 +57,7 @@ import org.apache.hadoop.mapred.InputSplit; import org.apache.hadoop.mapred.JobConf; import org.apache.hadoop.mapred.TextInputFormat; +import org.junit.Assert; import org.junit.Test; /** @@ -191,6 +192,21 @@ public void testScriptOperatorEnvVarsProcessing() throws Throwable { } } + public void testScriptOperatorBlacklistedEnvVarsProcessing() { + ScriptOperator scriptOperator = new ScriptOperator(); + + Configuration hconf = new JobConf(ScriptOperator.class); + + Map env = new HashMap(); + + HiveConf.setVar(hconf, HiveConf.ConfVars.HIVESCRIPT_ENV_BLACKLIST, "foobar"); + hconf.set("foobar", "foobar"); + hconf.set("barfoo", "barfoo"); + scriptOperator.addJobConfToEnvironment(hconf, env); + Assert.assertFalse(env.containsKey("foobar")); + Assert.assertTrue(env.containsKey("barfoo")); + } + public void testScriptOperator() throws Throwable { try { System.out.println("Testing Script Operator");