Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gremlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<name>ArcadeDB Gremlin</name>

<properties>
<gremlin.version>3.7.4</gremlin.version>
<gremlin.version>3.8.0</gremlin.version>
<translation.version>1.0.4</translation.version>
<snakeyaml.version>2.5</snakeyaml.version>
<netty.version>4.2.9.Final</netty.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -159,7 +158,7 @@ private boolean containersOfDifferentSize(final Object f, final Object s) {
};

private static <T> T throwTypeError() {
throw new GremlinTypeErrorException();
throw new IllegalStateException("Objects are not comparable");
}

/**
Expand Down Expand Up @@ -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

Expand Down
16 changes: 11 additions & 5 deletions gremlin/src/test/java/com/arcadedb/gremlin/GremlinTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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)));
Expand Down
Loading