diff --git a/gremlin/pom.xml b/gremlin/pom.xml index e0b48c534e..67e6a02a57 100644 --- a/gremlin/pom.xml +++ b/gremlin/pom.xml @@ -34,7 +34,7 @@ ArcadeDB Gremlin - 3.7.4 + 3.8.0 1.0.4 2.5 4.2.9.Final diff --git a/gremlin/src/main/java/org/apache/tinkerpop/gremlin/util/GremlinValueComparator.java b/gremlin/src/main/java/org/apache/tinkerpop/gremlin/util/GremlinValueComparator.java index 4707ec6e4a..dede8cb9bd 100644 --- a/gremlin/src/main/java/org/apache/tinkerpop/gremlin/util/GremlinValueComparator.java +++ b/gremlin/src/main/java/org/apache/tinkerpop/gremlin/util/GremlinValueComparator.java @@ -18,7 +18,6 @@ */ package org.apache.tinkerpop.gremlin.util; -import org.apache.tinkerpop.gremlin.process.traversal.GremlinTypeErrorException; import org.apache.tinkerpop.gremlin.process.traversal.Path; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Element; @@ -131,7 +130,7 @@ public boolean equals(final Object f, final Object s) { // comparable(f, s) assures that type(f) == type(s) final Type type = Type.type(f); return comparator(type).compare(f, s) == 0; - } catch (GremlinTypeErrorException ex) { + } catch (IllegalStateException ex) { /** * By routing through the compare(f, s) path we expose ourselves to type errors, which should be * reduced to false for equality: @@ -159,7 +158,7 @@ private boolean containersOfDifferentSize(final Object f, final Object s) { }; private static T throwTypeError() { - throw new GremlinTypeErrorException(); + throw new IllegalStateException("Objects are not comparable"); } /** @@ -300,8 +299,9 @@ private static boolean naturallyComparable(final Object f, final Object s) { /** * Return true if the two objects are of the same comparison type (although they may not be the exact same Class) + * Made public to allow TinkerPop 3.8.0 Compare class to access this method */ - private static boolean comparable(final Object f, final Object s) { + public static boolean comparable(final Object f, final Object s) { if (f == null || s == null) return f == s; // true iff both in the null space diff --git a/gremlin/src/test/java/com/arcadedb/gremlin/GremlinTest.java b/gremlin/src/test/java/com/arcadedb/gremlin/GremlinTest.java index e4b4e13cc7..d0241a6e1e 100644 --- a/gremlin/src/test/java/com/arcadedb/gremlin/GremlinTest.java +++ b/gremlin/src/test/java/com/arcadedb/gremlin/GremlinTest.java @@ -39,9 +39,11 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import java.io.*; -import java.math.*; -import java.util.*; +import java.io.File; +import java.io.PrintStream; +import java.math.BigInteger; +import java.util.List; +import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -427,6 +429,7 @@ void sort() { // ISSUE: https://github.com/ArcadeData/arcadedb/issues/911 // This test works only with Groovy engine, from v25.12.1 the default engine is Java + // Note: TinkerPop 3.8.0 changed behavior - now throws ArithmeticException on long overflow instead of promoting to BigInteger @Test void longOverflow() { GlobalConfiguration.GREMLIN_ENGINE.setValue("groovy"); @@ -435,9 +438,12 @@ void longOverflow() { Result value = graph.gremlin("g.inject(Long.MAX_VALUE, 0).sum()").execute().nextIfAvailable(); assertThat((long) value.getProperty("result")).isEqualTo(Long.MAX_VALUE); - value = graph.gremlin("g.inject(Long.MAX_VALUE, 1).sum()").execute().nextIfAvailable(); - assertThat((long) value.getProperty("result")).isEqualTo(Long.MAX_VALUE + 1); + // TinkerPop 3.8.0 throws ArithmeticException on long overflow + assertThatThrownBy(() -> graph.gremlin("g.inject(Long.MAX_VALUE, 1).sum()").execute().nextIfAvailable()) + .isInstanceOf(ArithmeticException.class) + .hasMessageContaining("long overflow"); + // Using BigInteger explicitly still works value = graph.gremlin("g.inject(BigInteger.valueOf(Long.MAX_VALUE), 1).sum()").execute().nextIfAvailable(); assertThat((BigInteger) value.getProperty("result")).isEqualTo( BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.valueOf(1L)));