static

in kyuubi-relocated-hive-metastore-client/src/main/java/org/apache/kyuubi/shaded/hive/metastore/security/HadoopThriftAuthBridge23.java [40:75]


  static {
    SASL_PROPERTIES_RESOLVER_CLASS = null;
    SASL_PROPS_FIELD = null;
    final String SASL_PROP_RES_CLASSNAME = "org.apache.hadoop.security.SaslPropertiesResolver";
    try {
      SASL_PROPERTIES_RESOLVER_CLASS = Class.forName(SASL_PROP_RES_CLASSNAME);

    } catch (ClassNotFoundException e) {
    }

    if (SASL_PROPERTIES_RESOLVER_CLASS != null) {
      // found the class, so this would be hadoop version 2.4 or newer (See
      // HADOOP-10221, HADOOP-10451)
      try {
        RES_GET_INSTANCE_METHOD =
            SASL_PROPERTIES_RESOLVER_CLASS.getMethod("getInstance", Configuration.class);
        GET_DEFAULT_PROP_METHOD = SASL_PROPERTIES_RESOLVER_CLASS.getMethod("getDefaultProperties");
      } catch (RuntimeException e) {
        throw e;
      } catch (Exception e) {
        // this must be hadoop 2.4 , where getDefaultProperties was protected
      }
    }

    if (SASL_PROPERTIES_RESOLVER_CLASS == null || GET_DEFAULT_PROP_METHOD == null) {
      // this must be a hadoop 2.4 version or earlier.
      // Resorting to the earlier method of getting the properties, which uses SASL_PROPS field
      try {
        SASL_PROPS_FIELD = SaslRpcServer.class.getField("SASL_PROPS");
      } catch (NoSuchFieldException e) {
        // Older version of hadoop should have had this field
        throw new IllegalStateException(
            "Error finding hadoop SASL_PROPS field in " + SaslRpcServer.class.getSimpleName(), e);
      }
    }
  }