private static URL findConfigFile()

in kyuubi-relocated-hive-metastore-client/src/main/java/org/apache/kyuubi/shaded/hive/metastore/conf/MetastoreConf.java [666:706]


  private static URL findConfigFile(ClassLoader classLoader, String name) {
    // First, look in the classpath
    URL result = classLoader.getResource(name);
    if (result == null) {
      // Nope, so look to see if our conf dir has been explicitly set
      result = seeIfConfAtThisLocation("METASTORE_CONF_DIR", name, false);
    }
    if (result == null) {
      // Nope, so look to see if our home dir has been explicitly set
      result = seeIfConfAtThisLocation("METASTORE_HOME", name, true);
    }
    if (result == null) {
      // Nope, so look to see if Hive's conf dir has been explicitly set
      result = seeIfConfAtThisLocation("HIVE_CONF_DIR", name, false);
    }
    if (result == null) {
      // Nope, so look to see if Hive's home dir has been explicitly set
      result = seeIfConfAtThisLocation("HIVE_HOME", name, true);
    }
    if (result == null) {
      // Nope, so look to see if we can find a conf file by finding our jar, going up one
      // directory, and looking for a conf directory.
      URI jarUri = null;
      try {
        jarUri = MetastoreConf.class.getProtectionDomain().getCodeSource().getLocation().toURI();
      } catch (Throwable e) {
        LOG.warn("Cannot get jar URI", e);
      }
      if (jarUri != null) {
        result = seeIfConfAtThisLocation(new File(jarUri).getParent(), name, true);
      }
    }

    if (result == null) {
      LOG.info("Unable to find config file: " + name);
    } else {
      LOG.info("Found configuration file: " + result);
    }

    return result;
  }