Repository: hive Updated Branches: refs/heads/master 3c7fb2a97 -> 4af249581
HIVE-17155: findConfFile() in HiveConf.java has some issues with the conf path (Aihua Xu, reviewed by Yongzhi Chen) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/4af24958 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/4af24958 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/4af24958 Branch: refs/heads/master Commit: 4af249581a4a25bd92c9c2dd9a09e590a0cf2831 Parents: 3c7fb2a Author: Aihua Xu <aihu...@apache.org> Authored: Tue Jul 25 08:14:40 2017 -0700 Committer: Aihua Xu <aihu...@apache.org> Committed: Tue Jul 25 08:14:40 2017 -0700 ---------------------------------------------------------------------- .../src/java/org/apache/hadoop/hive/conf/HiveConf.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/4af24958/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java ---------------------------------------------------------------------- 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 3cf76d0..f5e5974 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -161,19 +161,25 @@ public class HiveConf extends Configuration { result = checkConfigFile(new File(confPath, name)); if (result == null) { String homePath = System.getenv("HIVE_HOME"); - String nameInConf = "conf" + File.pathSeparator + name; + String nameInConf = "conf" + File.separator + name; result = checkConfigFile(new File(homePath, nameInConf)); if (result == null) { URI jarUri = null; try { - jarUri = HiveConf.class.getProtectionDomain().getCodeSource().getLocation().toURI(); + // Handle both file:// and jar:<url>!{entry} in the case of shaded hive libs + URL sourceUrl = HiveConf.class.getProtectionDomain().getCodeSource().getLocation(); + jarUri = sourceUrl.getProtocol().equalsIgnoreCase("jar") ? new URI(sourceUrl.getPath()) : sourceUrl.toURI(); } catch (Throwable e) { if (l4j.isInfoEnabled()) { l4j.info("Cannot get jar URI", e); } System.err.println("Cannot get jar URI: " + e.getMessage()); } - result = checkConfigFile(new File(new File(jarUri).getParentFile(), nameInConf)); + // From the jar file, the parent is /lib folder + File parent = new File(jarUri).getParentFile(); + if (parent != null) { + result = checkConfigFile(new File(parent.getParentFile(), nameInConf)); + } } } }