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

jmclean 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 0599025627 [#7636] add null check to BaseEntityCache validation (#7658)
0599025627 is described below

commit 05990256270791a8a6955ddee85cc62bc3312e8b
Author: Yunchi Pang <[email protected]>
AuthorDate: Thu Jul 10 17:39:24 2025 -0700

    [#7636] add null check to BaseEntityCache validation (#7658)
    
    ### What changes were proposed in this pull request?
    
    Add a null check before entity type check.
    
    ### Why are the changes needed?
    
    Previously, `validateEntityHasIdentifier` only validates the entity type
    but doesn't check if the entity is null before accessing its properties,
    which may cause misleading error messages.
    Fix: #7636
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Existing tests.
---
 core/src/main/java/org/apache/gravitino/cache/BaseEntityCache.java | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/src/main/java/org/apache/gravitino/cache/BaseEntityCache.java 
b/core/src/main/java/org/apache/gravitino/cache/BaseEntityCache.java
index b61cc93454..4f4b34e5e7 100644
--- a/core/src/main/java/org/apache/gravitino/cache/BaseEntityCache.java
+++ b/core/src/main/java/org/apache/gravitino/cache/BaseEntityCache.java
@@ -64,6 +64,7 @@ public abstract class BaseEntityCache implements EntityCache {
    * @param entity The {@link Entity} instance to check.
    */
   protected static void validateEntityHasIdentifier(Entity entity) {
+    Preconditions.checkArgument(entity != null, "Entity cannot be null");
     Preconditions.checkArgument(
         entity instanceof HasIdentifier, "Unsupported EntityType: " + 
entity.type());
   }

Reply via email to