This is an automated email from the ASF dual-hosted git repository.

jshao pushed a commit to branch branch-0.6
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/branch-0.6 by this push:
     new 0970a105c [#4408] Calls to code marked @VisibleForTesting in 
production code (#4490)
0970a105c is described below

commit 0970a105c41b620a2d3da9cfa3340429e5c91d80
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Aug 12 19:23:20 2024 +0800

    [#4408] Calls to code marked @VisibleForTesting in production code (#4490)
    
    # Pull Request Description
    
    **Title:** feat: Calls to code marked @VisibleForTesting in production
    code
    
    **Description:**
    This pull request addresses an issue where code marked with
    `@VisibleForTesting` was being called in production code. The
    `@VisibleForTesting` annotation is typically used to indicate that a
    method or class should only be accessed from within test code, and its
    presence in production code can lead to unintended consequences or
    misuse.
    
    **Changes:**
    - Removed the `@VisibleForTesting` annotation from the
    `loadCatalogBackend` method in `CatalogUtils`.
    
    **Impact:**
    - This change ensures that the `loadCatalogBackend` method is clearly
    marked for use in both production and test environments, aligning with
    its current usage.
    
    ---
    
    By addressing the use of `@VisibleForTesting` annotations in production,
    this pull request improves code clarity and maintainability.
    
    Co-authored-by: Naresh-kumar-Thodupunoori 
<[email protected]>
---
 .../catalog/hadoop/authentication/kerberos/KerberosClient.java       | 5 ++---
 .../gravitino/catalog/lakehouse/paimon/utils/CatalogUtils.java       | 2 --
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git 
a/catalogs/catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/authentication/kerberos/KerberosClient.java
 
b/catalogs/catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/authentication/kerberos/KerberosClient.java
index b8f31699d..4ea2fbdd9 100644
--- 
a/catalogs/catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/authentication/kerberos/KerberosClient.java
+++ 
b/catalogs/catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/authentication/kerberos/KerberosClient.java
@@ -65,9 +65,8 @@ public class KerberosClient implements Closeable {
 
     // Login
     UserGroupInformation.setConfiguration(hadoopConf);
-    UserGroupInformation kerberosLoginUgi =
-        UserGroupInformation.loginUserFromKeytabAndReturnUGI(catalogPrincipal, 
keytabFilePath);
-    UserGroupInformation.setLoginUser(kerberosLoginUgi);
+    UserGroupInformation.loginUserFromKeytab(catalogPrincipal, keytabFilePath);
+    UserGroupInformation kerberosLoginUgi = 
UserGroupInformation.getLoginUser();
 
     // Refresh the cache if it's out of date.
     if (refreshCredentials) {
diff --git 
a/catalogs/catalog-lakehouse-paimon/src/main/java/org/apache/gravitino/catalog/lakehouse/paimon/utils/CatalogUtils.java
 
b/catalogs/catalog-lakehouse-paimon/src/main/java/org/apache/gravitino/catalog/lakehouse/paimon/utils/CatalogUtils.java
index fcc4f3088..848063904 100644
--- 
a/catalogs/catalog-lakehouse-paimon/src/main/java/org/apache/gravitino/catalog/lakehouse/paimon/utils/CatalogUtils.java
+++ 
b/catalogs/catalog-lakehouse-paimon/src/main/java/org/apache/gravitino/catalog/lakehouse/paimon/utils/CatalogUtils.java
@@ -24,7 +24,6 @@ import static 
org.apache.gravitino.catalog.lakehouse.paimon.PaimonConfig.CATALOG
 import static 
org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION;
 import static 
org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION;
 
-import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import java.io.File;
 import java.util.Map;
@@ -46,7 +45,6 @@ public class CatalogUtils {
 
   private CatalogUtils() {}
 
-  @VisibleForTesting
   public static PaimonBackendCatalogWrapper loadCatalogBackend(PaimonConfig 
paimonConfig) {
     Map<String, String> allConfig = paimonConfig.getAllConfig();
     AuthenticationConfig authenticationConfig = new 
AuthenticationConfig(allConfig);

Reply via email to