commit 5e99be45ea3389d4210955ba8b0db4b7441a15e6 Author: David Lavati Date: Sun Apr 19 19:30:02 2020 +0200 HIVE-23088 Using Strings from log4j breaks non-log4j users Change-Id: I10672a5d4c71d1630a523b7e3ef186005a1c795f diff --git itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java index bbcada9eda..0e41ee9a32 100644 --- itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java +++ itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java @@ -113,7 +113,6 @@ import org.apache.hive.common.util.StreamPrinter; import org.apache.hive.druid.MiniDruidCluster; import org.apache.hive.kafka.SingleNodeKafkaCluster; -import org.apache.logging.log4j.util.Strings; import org.apache.tools.ant.BuildException; import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher; @@ -413,7 +412,7 @@ private void setFsRelatedProperties(HiveConf conf, boolean isLocalFs, FileSystem Path userInstallPath; if (isLocalFs) { String buildDir = System.getProperty(BUILD_DIR_PROPERTY); - Preconditions.checkState(Strings.isNotBlank(buildDir)); + Preconditions.checkState(StringUtils.isNotBlank(buildDir)); Path path = new Path(fsUriString, buildDir); // Create a fake fs root for local fs @@ -2081,7 +2080,7 @@ public static boolean queryListRunnerSingleThreaded(File[] qfiles, QTestUtil[] q .append(qfiles[i].getName()) .append(" results check failed with error code ") .append(result.getReturnCode()); - if (Strings.isNotEmpty(result.getCapturedOutput())) { + if (StringUtils.isNotEmpty(result.getCapturedOutput())) { builder.append(" and diff value ").append(result.getCapturedOutput()); } System.err.println(builder.toString()); @@ -2139,7 +2138,7 @@ public static boolean queryListRunnerMultiThreaded(File[] qfiles, QTestUtil[] qt .append(qfiles[i].getName()) .append(" results check failed with error code ") .append(result.getReturnCode()); - if (Strings.isNotEmpty(result.getCapturedOutput())) { + if (StringUtils.isNotEmpty(result.getCapturedOutput())) { builder.append(" and diff value ").append(result.getCapturedOutput()); } System.err.println(builder.toString()); diff --git ql/src/java/org/apache/hadoop/hive/ql/hooks/HookUtils.java ql/src/java/org/apache/hadoop/hive/ql/hooks/HookUtils.java index 0841d679c5..58e95e170f 100644 --- ql/src/java/org/apache/hadoop/hive/ql/hooks/HookUtils.java +++ ql/src/java/org/apache/hadoop/hive/ql/hooks/HookUtils.java @@ -21,10 +21,10 @@ import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.conf.HiveConf.ConfVars; import org.apache.hadoop.hive.ql.exec.Utilities; -import org.apache.logging.log4j.util.Strings; public class HookUtils { @@ -47,7 +47,7 @@ public static String redactLogString(HiveConf conf, String logString) throws InstantiationException, IllegalAccessException, ClassNotFoundException { String csHooks = conf.getVar(hookConfVar); List hooks = new ArrayList<>(); - if (Strings.isBlank(csHooks)) { + if (StringUtils.isBlank(csHooks)) { return hooks; } String[] hookClasses = csHooks.split(","); diff --git service/src/java/org/apache/hive/service/server/HiveServer2.java service/src/java/org/apache/hive/service/server/HiveServer2.java index e72ab59b62..9396068247 100644 --- service/src/java/org/apache/hive/service/server/HiveServer2.java +++ service/src/java/org/apache/hive/service/server/HiveServer2.java @@ -111,7 +111,6 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; -import org.apache.logging.log4j.util.Strings; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.WatchedEvent; @@ -323,7 +322,7 @@ public void run() { if (hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_WEBUI_USE_SSL)) { String keyStorePath = hiveConf.getVar( ConfVars.HIVE_SERVER2_WEBUI_SSL_KEYSTORE_PATH); - if (Strings.isBlank(keyStorePath)) { + if (StringUtils.isBlank(keyStorePath)) { throw new IllegalArgumentException( ConfVars.HIVE_SERVER2_WEBUI_SSL_KEYSTORE_PATH.varname + " Not configured for SSL connection"); @@ -338,7 +337,7 @@ public void run() { ConfVars.HIVE_SERVER2_WEBUI_SPNEGO_PRINCIPAL); String spnegoKeytab = hiveConf.getVar( ConfVars.HIVE_SERVER2_WEBUI_SPNEGO_KEYTAB); - if (Strings.isBlank(spnegoPrincipal) || Strings.isBlank(spnegoKeytab)) { + if (StringUtils.isBlank(spnegoPrincipal) || StringUtils.isBlank(spnegoKeytab)) { throw new IllegalArgumentException( ConfVars.HIVE_SERVER2_WEBUI_SPNEGO_PRINCIPAL.varname + "/" + ConfVars.HIVE_SERVER2_WEBUI_SPNEGO_KEYTAB.varname @@ -353,7 +352,8 @@ public void run() { String allowedOrigins = hiveConf.getVar(ConfVars.HIVE_SERVER2_WEBUI_CORS_ALLOWED_ORIGINS); String allowedMethods = hiveConf.getVar(ConfVars.HIVE_SERVER2_WEBUI_CORS_ALLOWED_METHODS); String allowedHeaders = hiveConf.getVar(ConfVars.HIVE_SERVER2_WEBUI_CORS_ALLOWED_HEADERS); - if (Strings.isBlank(allowedOrigins) || Strings.isBlank(allowedMethods) || Strings.isBlank(allowedHeaders)) { + if (StringUtils.isBlank(allowedOrigins) || StringUtils.isBlank(allowedMethods) || StringUtils + .isBlank(allowedHeaders)) { throw new IllegalArgumentException("CORS enabled. But " + ConfVars.HIVE_SERVER2_WEBUI_CORS_ALLOWED_ORIGINS.varname + "/" + ConfVars.HIVE_SERVER2_WEBUI_CORS_ALLOWED_METHODS.varname + "/" +