This is an automated email from the ASF dual-hosted git repository.
xiazcy pushed a commit to branch 3.7-dev
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
The following commit(s) were added to refs/heads/3.7-dev by this push:
new d5f4a29535 Fix NPE in dateDiff exception message & fix bullet list
formatting in semantics doc CTR
d5f4a29535 is described below
commit d5f4a2953562ff8c081efe224a81484e8190f580
Author: xiazcy <[email protected]>
AuthorDate: Fri Aug 22 15:31:02 2025 -0700
Fix NPE in dateDiff exception message & fix bullet list formatting in
semantics doc CTR
---
docs/src/dev/provider/gremlin-semantics.asciidoc | 11 +++++++++++
.../gremlin/process/traversal/step/map/DateDiffStep.java | 2 +-
.../gremlin/process/traversal/step/map/DateDiffStepTest.java | 5 +++++
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/docs/src/dev/provider/gremlin-semantics.asciidoc
b/docs/src/dev/provider/gremlin-semantics.asciidoc
index 399ab1d5b7..a58fdda374 100644
--- a/docs/src/dev/provider/gremlin-semantics.asciidoc
+++ b/docs/src/dev/provider/gremlin-semantics.asciidoc
@@ -610,6 +610,7 @@ None
Incoming date remains unchanged.
*Exceptions*
+
* If the incoming traverser is a non-String/Number/Date value then an
`IllegalArgumentException` will be thrown.
See:
link:https://github.com/apache/tinkerpop/tree/x.y.z/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AsDateStep.java[source],
@@ -639,6 +640,7 @@ list of string instead.
Null values from the incoming traverser are not processed and remain as null
when returned.
*Exceptions*
+
None
See:
link:https://github.com/apache/tinkerpop/tree/x.y.z/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AsStringGlobalStep.java[source],
@@ -1063,6 +1065,7 @@ The `global` scope will operate on individual string
traverser. The `local` scop
Null values from the incoming traverser are not processed and remain as null
when returned.
*Exceptions*
+
* For `Scope.global` or parameterless function calls, if the incoming
traverser is a non-String value then an `IllegalArgumentException` will be
thrown.
* For `Scope.local`, if the incoming traverser is not a string or a list of
strings then an `IllegalArgumentException` will be thrown.
@@ -1161,6 +1164,7 @@ The `global` scope will operate on individual string
traverser. The `local` scop
Null values from the incoming traverser are not processed and remain as null
when returned.
*Exceptions*
+
* For `Scope.global` or parameterless function calls, if the incoming
traverser is a non-String value then an `IllegalArgumentException` will be
thrown.
* For `Scope.local`, if the incoming traverser is not a string or a list of
strings then an `IllegalArgumentException` will be thrown.
@@ -1478,6 +1482,7 @@ The `global` scope will operate on individual string
traverser. The `local` scop
Null values from the incoming traverser are not processed and remain as null
when returned.
*Exceptions*
+
* For `Scope.global` or parameterless function calls, if the incoming
traverser is a non-String value then an `IllegalArgumentException` will be
thrown.
* For `Scope.local`, if the incoming traverser is not a string or a list of
strings then an `IllegalArgumentException` will be thrown.
@@ -1534,6 +1539,7 @@ The `global` scope will operate on individual string
traverser. The `local` scop
Null values from the incoming traverser are not processed and remain as null
when returned.
*Exceptions*
+
* For `Scope.global` or parameterless function calls, if the incoming
traverser is a non-String value then an `IllegalArgumentException` will be
thrown.
* For `Scope.local`, if the incoming traverser is not a string or a list of
strings then an `IllegalArgumentException` will be thrown.
@@ -1564,6 +1570,7 @@ The `global` scope will operate on individual string
traverser. The `local` scop
Null values from the incoming traverser are not processed and remain as null
when returned.
*Exceptions*
+
* For `Scope.global` or parameterless function calls, if the incoming
traverser is a non-String value then an `IllegalArgumentException` will be
thrown.
* For `Scope.local`, if the incoming traverser is not a string or a list of
strings then an `IllegalArgumentException` will be thrown.
@@ -1596,6 +1603,7 @@ The `global` scope will operate on individual string
traverser. The `local` scop
Null values from the incoming traverser are not processed and remain as null
when returned.
*Exceptions*
+
* For `Scope.global` or parameterless function calls, if the incoming
traverser is a non-String value then an `IllegalArgumentException` will be
thrown.
* For `Scope.local`, if the incoming traverser is not a string or a list of
strings then an `IllegalArgumentException` will be thrown.
@@ -1625,6 +1633,7 @@ The `global` scope will operate on individual string
traverser. The `local` scop
Null values from the incoming traverser are not processed and remain as null
when returned.
*Exceptions*
+
* For `Scope.global` or parameterless function calls, if the incoming
traverser is a non-String value then an `IllegalArgumentException` will be
thrown.
* For `Scope.local`, if the incoming traverser is not a string or a list of
strings then an `IllegalArgumentException` will be thrown.
@@ -1654,6 +1663,7 @@ The `global` scope will operate on individual string
traverser. The `local` scop
Null values from the incoming traverser are not processed and remain as null
when returned.
*Exceptions*
+
* For `Scope.global` or parameterless function calls, if the incoming
traverser is a non-String value then an `IllegalArgumentException` will be
thrown.
* For `Scope.local`, if the incoming traverser is not a string or a list of
strings then an `IllegalArgumentException` will be thrown.
@@ -1682,6 +1692,7 @@ The `global` scope will operate on individual string
traverser. The `local` scop
Null values from the incoming traverser are not processed and remain as null
when returned.
*Exceptions*
+
* For `Scope.global` or parameterless function calls, if the incoming
traverser is a non-String value then an `IllegalArgumentException` will be
thrown.
* For `Scope.local`, if the incoming traverser is not a string or a list of
strings then an `IllegalArgumentException` will be thrown.
diff --git
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/DateDiffStep.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/DateDiffStep.java
index d15d461845..52d0bd2cbe 100644
---
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/DateDiffStep.java
+++
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/DateDiffStep.java
@@ -55,7 +55,7 @@ public final class DateDiffStep<S> extends ScalarMapStep<S,
Long> implements Tra
if (!(object instanceof Date))
throw new IllegalArgumentException(
- String.format("DateDiff can only take Date as argument,
encountered %s", object.getClass()));
+ String.format("DateDiff can only take Date as argument,
encountered %s", object == null ? null : object.getClass()));
final Date otherDate = value != null ? value :
dateTraversal != null ? TraversalUtil.apply(traverser,
dateTraversal) : null;
diff --git
a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/DateDiffStepTest.java
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/DateDiffStepTest.java
index 0cffa601ba..e8de2d8681 100644
---
a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/DateDiffStepTest.java
+++
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/DateDiffStepTest.java
@@ -96,4 +96,9 @@ public class DateDiffStepTest extends StepTest {
public void shouldThrowWhenInputIsNotDate() {
__.__("2023-08-23T00:00:00Z").dateDiff(new Date()).next();
}
+
+ @Test(expected = IllegalArgumentException.class)
+ public void shouldThrowWhenInputIsNull() {
+ __.__((Object) null).dateDiff(new Date()).next();
+ }
}