World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#8304] fix: Possible NPE in LineageService (#8997)
Sambhavi Pandeya8c116150171
diff --git a/lineage/src/main/java/org/apache/gravitino/lineage/LineageService.java b/lineage/src/main/java/org/apache/gravitino/lineage/LineageService.javaindex 0bd4f1c67c..e5ff02dee7 100644--- a/lineage/src/main/java/org/apache/gravitino/lineage/LineageService.java+++ b/lineage/src/main/java/org/apache/gravitino/lineage/LineageService.java@@ -65,10 +65,12 @@ public class LineageService implements LineageDispatcher, SupportsRESTPackages {@Overridepublic boolean dispatchLineageEvent(OpenLineage.RunEvent runEvent) {+ if (runEvent == null) {+ return false;+ }if (sinkManager.isHighWatermark()) {return false;}-RunEvent newEvent = processor.process(runEvent);sinkManager.sink(newEvent);return true;diff --git a/lineage/src/test/java/org/apache/gravitino/lineage/TestLineageService.java b/lineage/src/test/java/org/apache/gravitino/lineage/TestLineageService.javanew file mode 100644index 0000000000..4e3f52c948--- /dev/null+++ b/lineage/src/test/java/org/apache/gravitino/lineage/TestLineageService.java@@ -0,0 +1,32 @@+/*+ * 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.lineage;++import org.junit.jupiter.api.Assertions;+import org.junit.jupiter.api.Test;++class TestLineageService {+ @Test+ void testDispatchLineageEventWithoutInitialization() {+ try (LineageService service = new LineageService()) {+ Assertions.assertFalse(service.dispatchLineageEvent(null));+ }+ }+}