Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

Fix potential NullPointerException in UserContext by adding null check for parentContext. (#4348)

kartik4249993aa868
diff --git a/catalogs/catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/authentication/UserContext.java b/catalogs/catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/authentication/UserContext.java
index 1023be45f4..3bf84adbbe 100644
--- a/catalogs/catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/authentication/UserContext.java
+++ b/catalogs/catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/authentication/UserContext.java
@@ -125,7 +125,7 @@ public abstract class UserContext implements Closeable {
} else if (authenticationType == AuthenticationType.KERBEROS) {
// if the kerberos authentication is inherited from the parent context, we will use the
// parent context's kerberos configuration.
- if (authenticationConfig.isSimpleAuth()) {
+ if (parentContext != null && authenticationConfig.isSimpleAuth()) {
KerberosUserContext kerberosUserContext = ((KerberosUserContext) parentContext).deepCopy();
kerberosUserContext.setEnableUserImpersonation(enableUserImpersonation);
addUserContext(nameIdentifier, kerberosUserContext);