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 36c69a32db [#10134] fix(catalog): prevent NPE when filesetChanges is 
null (#10135)
36c69a32db is described below

commit 36c69a32db8be244ad8f69498acab0f1c2ed31c6
Author: a638011 <[email protected]>
AuthorDate: Fri Mar 6 09:25:21 2026 +0800

    [#10134] fix(catalog): prevent NPE when filesetChanges is null (#10135)
    
    ### What changes were proposed in this pull request?
    
    Fix a potential NullPointerException in AlterFilesetFailureEvent when
    filesetChanges is null.
    
    ### Why are the changes needed?
    
    When filesetChanges is null, the constructor calls
    filesetChanges.clone() which throws NPE. This can happen in failure
    scenarios where the changes array is not available.
    
    Fix issue #10134
    
    ### Does this PR introduce any user-facing changes?
    
    No
    
    ### How was this patch tested?
    
    Added unit test AlterFilesetFailureEventTest that verifies null
    filesetChanges does not throw NPE.
---
 .../api/event/AlterFilesetFailureEvent.java        |  2 +-
 .../api/event/AlterFilesetFailureEventTest.java    | 38 ++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterFilesetFailureEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/AlterFilesetFailureEvent.java
index f437612668..eb19a31190 100644
--- 
a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterFilesetFailureEvent.java
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/AlterFilesetFailureEvent.java
@@ -45,7 +45,7 @@ public final class AlterFilesetFailureEvent extends 
FilesetFailureEvent {
   public AlterFilesetFailureEvent(
       String user, NameIdentifier identifier, Exception exception, 
FilesetChange[] filesetChanges) {
     super(user, identifier, exception);
-    this.filesetChanges = filesetChanges.clone();
+    this.filesetChanges = filesetChanges == null ? null : 
filesetChanges.clone();
   }
 
   /**
diff --git 
a/core/src/test/java/org/apache/gravitino/listener/api/event/AlterFilesetFailureEventTest.java
 
b/core/src/test/java/org/apache/gravitino/listener/api/event/AlterFilesetFailureEventTest.java
new file mode 100644
index 0000000000..806870c7a0
--- /dev/null
+++ 
b/core/src/test/java/org/apache/gravitino/listener/api/event/AlterFilesetFailureEventTest.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class AlterFilesetFailureEventTest {
+
+  @Test
+  public void testNullFilesetChangesDoesNotThrow() {
+    Assertions.assertDoesNotThrow(
+        () ->
+            new AlterFilesetFailureEvent(
+                "user",
+                NameIdentifier.of("metalake", "catalog", "fileset"),
+                new Exception(),
+                null));
+  }
+}

Reply via email to