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 a8c1161501 [#8304] fix: Possible NPE in LineageService (#8997)
a8c1161501 is described below
commit a8c116150171a12eec27f10a3e1c6c886eef810f
Author: Sambhavi Pandey <[email protected]>
AuthorDate: Mon Nov 3 04:09:13 2025 +0530
[#8304] fix: Possible NPE in LineageService (#8997)
### What changes were proposed in this pull request?
Add a null check for the argument in dispatchLineageEvent and return
false if it is null.
### Why are the changes needed?
The method dispatchLineageEvent can throw a NullPointerException if
called without proper initialization or with a null argument.
Fix: (#8304 )
### Does this PR introduce _any_ user-facing change?
no
### How was this patch tested?
unit testing
---
.../apache/gravitino/lineage/LineageService.java | 4 ++-
.../gravitino/lineage/TestLineageService.java | 32 ++++++++++++++++++++++
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git
a/lineage/src/main/java/org/apache/gravitino/lineage/LineageService.java
b/lineage/src/main/java/org/apache/gravitino/lineage/LineageService.java
index 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 {
@Override
public 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.java
new file mode 100644
index 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));
+ }
+ }
+}