This is an automated email from the ASF dual-hosted git repository.
jshao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new eacdeabae [#4408] Calls to code marked @VisibleForTesting in
production code (#4426)
eacdeabae is described below
commit eacdeabae9e6125282fd69a247ef686ef9f8bbd1
Author: Naresh-kumar-Thodupunoori
<[email protected]>
AuthorDate: Mon Aug 12 15:47:20 2024 +0530
[#4408] Calls to code marked @VisibleForTesting in production code (#4426)
# 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.
---
.../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);