Skip to content

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

[#10134] fix(catalog): prevent NPE when filesetChanges is null (#10135)

a63801136c69a32db8b
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));
+ }
+}