Code review comment: Method `loginUserFromKeytabAndReturnUGI` does't set the current login user but `loginUserFromKeytab` does, I've used `loginUserFromKeytab` instead.

Code under review:
protected void initLocalObjectsImpl() {
        HiveConf hiveConf = new HiveConf();
        for (String key : catalogProperty.getHdfsProperties().keySet()) {
            String val = catalogProperty.getOrDefault(key, "");
            hiveConf.set(key, val);
        }

        String authentication = catalogProperty.getOrDefault(
                HdfsResource.HADOOP_SECURITY_AUTHENTICATION, "");
        if (AuthType.KERBEROS.getDesc().equals(authentication)) {
            Configuration conf = new Configuration();
            conf.set(HdfsResource.HADOOP_SECURITY_AUTHENTICATION, authentication);
            UserGroupInformation.setConfiguration(conf);
            final UserGroupInformation ugi;
            try {
                /**
                 * Because metastore client is created by using
                 * {@link org.apache.hadoop.hive.metastore.RetryingMetaStoreClient
                 * it will relogin when TGT is expired, so we don't need to relogin manually.
                 */
                ugi = UserGroupInformation.loginUserFromKeytabAndReturnUGI(
                    catalogProperty.getOrDefault(HdfsResource.HADOOP_KERBEROS_PRINCIPAL, ""),
                    catalogProperty.getOrDefault(HdfsResource.HADOOP_KERBEROS_KEYTAB, ""));
                UserGroupInformation.setLoginUser(ugi);
            } catch (IOException e) {
                throw new HMSClientException("login with kerberos auth failed for catalog %s", e, this.getName());
            }
        }
        
        
        Map<String, String> properties = HiveMetaStoreClientHelper.getPropertiesForDLF(name, hiveConf);
        properties.putAll(catalogProperty.getProperties());
        catalogProperty.setProperties(properties);

        
        client = new PooledHiveMetaStoreClient(hiveConf, MAX_CLIENT_POOL_SIZE);
    }

Line commented on: UserGroupInformation.setLoginUser(ugi);

Revised code:
protected void initLocalObjectsImpl() {
        HiveConf hiveConf = new HiveConf();
        for (String key : catalogProperty.getHdfsProperties().keySet()) {
            String val = catalogProperty.getOrDefault(key, "");
            hiveConf.set(key, val);
        }

        String authentication = catalogProperty.getOrDefault(
                HdfsResource.HADOOP_SECURITY_AUTHENTICATION, "");
        if (AuthType.KERBEROS.getDesc().equals(authentication)) {
            Configuration conf = new Configuration();
            conf.set(HdfsResource.HADOOP_SECURITY_AUTHENTICATION, authentication);
            UserGroupInformation.setConfiguration(conf);
            try {
                /**
                 * Because metastore client is created by using
                 * {@link org.apache.hadoop.hive.metastore.RetryingMetaStoreClient
                 * it will relogin when TGT is expired, so we don't need to relogin manually.
                 */
                UserGroupInformation.loginUserFromKeytab(
                        catalogProperty.getOrDefault(HdfsResource.HADOOP_KERBEROS_PRINCIPAL, ""),
                        catalogProperty.getOrDefault(HdfsResource.HADOOP_KERBEROS_KEYTAB, ""));
            } catch (IOException e) {
                throw new HMSClientException("login with kerberos auth failed for catalog %s", e, this.getName());
            }
        }
        
        
        Map<String, String> properties = HiveMetaStoreClientHelper.getPropertiesForDLF(name, hiveConf);
        properties.putAll(catalogProperty.getProperties());
        catalogProperty.setProperties(properties);

        
        client = new PooledHiveMetaStoreClient(hiveConf, MAX_CLIENT_POOL_SIZE);
    }