Skip to content

Commit d5f4a29

Browse files
committed
Fix NPE in dateDiff exception message & fix bullet list formatting in semantics doc CTR
1 parent a20f386 commit d5f4a29

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

docs/src/dev/provider/gremlin-semantics.asciidoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ None
610610
Incoming date remains unchanged.
611611
612612
*Exceptions*
613+
613614
* If the incoming traverser is a non-String/Number/Date value then an `IllegalArgumentException` will be thrown.
614615
615616
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.
639640
Null values from the incoming traverser are not processed and remain as null when returned.
640641
641642
*Exceptions*
643+
642644
None
643645
644646
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
10631065
Null values from the incoming traverser are not processed and remain as null when returned.
10641066
10651067
*Exceptions*
1068+
10661069
* For `Scope.global` or parameterless function calls, if the incoming traverser is a non-String value then an `IllegalArgumentException` will be thrown.
10671070
* For `Scope.local`, if the incoming traverser is not a string or a list of strings then an `IllegalArgumentException` will be thrown.
10681071
@@ -1161,6 +1164,7 @@ The `global` scope will operate on individual string traverser. The `local` scop
11611164
Null values from the incoming traverser are not processed and remain as null when returned.
11621165
11631166
*Exceptions*
1167+
11641168
* For `Scope.global` or parameterless function calls, if the incoming traverser is a non-String value then an `IllegalArgumentException` will be thrown.
11651169
* For `Scope.local`, if the incoming traverser is not a string or a list of strings then an `IllegalArgumentException` will be thrown.
11661170
@@ -1478,6 +1482,7 @@ The `global` scope will operate on individual string traverser. The `local` scop
14781482
Null values from the incoming traverser are not processed and remain as null when returned.
14791483
14801484
*Exceptions*
1485+
14811486
* For `Scope.global` or parameterless function calls, if the incoming traverser is a non-String value then an `IllegalArgumentException` will be thrown.
14821487
* For `Scope.local`, if the incoming traverser is not a string or a list of strings then an `IllegalArgumentException` will be thrown.
14831488
@@ -1534,6 +1539,7 @@ The `global` scope will operate on individual string traverser. The `local` scop
15341539
Null values from the incoming traverser are not processed and remain as null when returned.
15351540
15361541
*Exceptions*
1542+
15371543
* For `Scope.global` or parameterless function calls, if the incoming traverser is a non-String value then an `IllegalArgumentException` will be thrown.
15381544
* For `Scope.local`, if the incoming traverser is not a string or a list of strings then an `IllegalArgumentException` will be thrown.
15391545
@@ -1564,6 +1570,7 @@ The `global` scope will operate on individual string traverser. The `local` scop
15641570
Null values from the incoming traverser are not processed and remain as null when returned.
15651571
15661572
*Exceptions*
1573+
15671574
* For `Scope.global` or parameterless function calls, if the incoming traverser is a non-String value then an `IllegalArgumentException` will be thrown.
15681575
* For `Scope.local`, if the incoming traverser is not a string or a list of strings then an `IllegalArgumentException` will be thrown.
15691576
@@ -1596,6 +1603,7 @@ The `global` scope will operate on individual string traverser. The `local` scop
15961603
Null values from the incoming traverser are not processed and remain as null when returned.
15971604
15981605
*Exceptions*
1606+
15991607
* For `Scope.global` or parameterless function calls, if the incoming traverser is a non-String value then an `IllegalArgumentException` will be thrown.
16001608
* For `Scope.local`, if the incoming traverser is not a string or a list of strings then an `IllegalArgumentException` will be thrown.
16011609
@@ -1625,6 +1633,7 @@ The `global` scope will operate on individual string traverser. The `local` scop
16251633
Null values from the incoming traverser are not processed and remain as null when returned.
16261634
16271635
*Exceptions*
1636+
16281637
* For `Scope.global` or parameterless function calls, if the incoming traverser is a non-String value then an `IllegalArgumentException` will be thrown.
16291638
* For `Scope.local`, if the incoming traverser is not a string or a list of strings then an `IllegalArgumentException` will be thrown.
16301639
@@ -1654,6 +1663,7 @@ The `global` scope will operate on individual string traverser. The `local` scop
16541663
Null values from the incoming traverser are not processed and remain as null when returned.
16551664
16561665
*Exceptions*
1666+
16571667
* For `Scope.global` or parameterless function calls, if the incoming traverser is a non-String value then an `IllegalArgumentException` will be thrown.
16581668
* For `Scope.local`, if the incoming traverser is not a string or a list of strings then an `IllegalArgumentException` will be thrown.
16591669
@@ -1682,6 +1692,7 @@ The `global` scope will operate on individual string traverser. The `local` scop
16821692
Null values from the incoming traverser are not processed and remain as null when returned.
16831693
16841694
*Exceptions*
1695+
16851696
* For `Scope.global` or parameterless function calls, if the incoming traverser is a non-String value then an `IllegalArgumentException` will be thrown.
16861697
* For `Scope.local`, if the incoming traverser is not a string or a list of strings then an `IllegalArgumentException` will be thrown.
16871698

gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/DateDiffStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected Long map(final Traverser.Admin<S> traverser) {
5555

5656
if (!(object instanceof Date))
5757
throw new IllegalArgumentException(
58-
String.format("DateDiff can only take Date as argument, encountered %s", object.getClass()));
58+
String.format("DateDiff can only take Date as argument, encountered %s", object == null ? null : object.getClass()));
5959

6060
final Date otherDate = value != null ? value :
6161
dateTraversal != null ? TraversalUtil.apply(traverser, dateTraversal) : null;

gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/DateDiffStepTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,9 @@ public void shouldHandleNullDate() {
9696
public void shouldThrowWhenInputIsNotDate() {
9797
__.__("2023-08-23T00:00:00Z").dateDiff(new Date()).next();
9898
}
99+
100+
@Test(expected = IllegalArgumentException.class)
101+
public void shouldThrowWhenInputIsNull() {
102+
__.__((Object) null).dateDiff(new Date()).next();
103+
}
99104
}

0 commit comments

Comments
 (0)