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.8.0</gremlin.version>
<gremlin.version>3.7.4</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,6 +18,7 @@
*/
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 @@ -130,7 +131,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 (IllegalStateException ex) {
} catch (GremlinTypeErrorException 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 @@ -158,7 +159,7 @@ private boolean containersOfDifferentSize(final Object f, final Object s) {
};

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

/**
Expand Down Expand Up @@ -299,9 +300,8 @@ 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
*/
public static boolean comparable(final Object f, final Object s) {
private 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: 5 additions & 11 deletions gremlin/src/test/java/com/arcadedb/gremlin/GremlinTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.List;
import java.util.UUID;
import java.io.*;
import java.math.*;
import java.util.*;
Comment on lines +42 to +44
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to common Java style guides, such as the Google Java Style Guide, using wildcard imports is discouraged. They can obscure which classes are actually used, leading to less readable code and potential naming conflicts. It's better to use explicit imports for improved clarity and maintainability. Please consider using specific class imports instead.

Suggested change
import java.io.*;
import java.math.*;
import java.util.*;
import java.io.File;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
References
  1. The Google Java Style Guide (section 3.3.1) states that wildcard imports, static or otherwise, are not to be used. This is to improve clarity and avoid potential naming collisions. (link)


import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
Expand Down Expand Up @@ -429,7 +427,6 @@ 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 @@ -438,12 +435,9 @@ void longOverflow() {
Result value = graph.gremlin("g.inject(Long.MAX_VALUE, 0).sum()").execute().nextIfAvailable();
assertThat((long) value.getProperty("result")).isEqualTo(Long.MAX_VALUE);

// 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");
value = graph.gremlin("g.inject(Long.MAX_VALUE, 1).sum()").execute().nextIfAvailable();
assertThat((long) value.getProperty("result")).isEqualTo(Long.MAX_VALUE + 1);

// 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