From 32ea0b1192b3cd2dfa8aa12fc0e55ef2ec48ccb1 Mon Sep 17 00:00:00 2001 From: leventov Date: Sat, 17 Mar 2018 16:56:23 +0100 Subject: [PATCH] Use error-prone compiler --- .../jsr223/DefaultScriptCustomizer.java | 5 +- .../step/map/PageRankVertexProgramStep.java | 2 +- .../map/PeerPressureVertexProgramStep.java | 2 +- .../ComputerFinalizationStrategy.java | 3 +- .../optimization/GraphFilterStrategy.java | 8 +- .../process/computer/util/ComputerGraph.java | 2 +- .../process/traversal/TraversalStrategy.java | 127 +++++++++--------- .../util/DefaultTraversalMetrics.java | 2 +- .../structure/io/graphson/GraphSONReader.java | 5 +- .../gremlin/structure/io/gryo/GryoMapper.java | 2 +- .../gremlin/structure/io/gryo/GryoReader.java | 5 +- .../star/StarGraphGraphSONDeserializer.java | 5 +- .../tinkerpop/gremlin/util/TimeUtil.java | 3 +- .../process/computer/GraphFilterTest.java | 26 ++-- .../traversal/OperatorExceptionTest.java | 18 ++- .../decoration/SubgraphStrategyTest.java | 3 +- .../RepeatUnrollStrategyTest.java | 2 +- .../util/function/FunctionUtilsTest.java | 13 +- .../tinkerpop/gremlin/driver/ResultQueue.java | 2 +- .../process/computer/GraphComputerTest.java | 24 ++-- .../process/traversal/step/map/PathTest.java | 2 +- .../step/sideEffect/GroupCountTest.java | 2 +- .../traversal/step/sideEffect/GroupTest.java | 8 +- .../SubgraphStrategyProcessTest.java | 8 +- .../structure/io/AbstractIoRegistryCheck.java | 4 +- .../structure/io/ObjectWritableTest.java | 4 +- pom.xml | 18 ++- .../computer/TinkerGraphComputerView.java | 2 +- .../tinkergraph/structure/TinkerIndex.java | 4 +- 29 files changed, 174 insertions(+), 137 deletions(-) diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizer.java index c996caeb8e9..653450acbc4 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizer.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultScriptCustomizer.java @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Default implementation of the {@link ScriptCustomizer} that can create the script list from a list of files or @@ -39,7 +40,9 @@ public class DefaultScriptCustomizer implements ScriptCustomizer { public DefaultScriptCustomizer(final List files) { this(files.stream().map(f -> { try { - return Files.lines(f.toPath(), StandardCharsets.UTF_8).collect(Collectors.toList()); + try (Stream lines = Files.lines(f.toPath(), StandardCharsets.UTF_8)) { + return lines.collect(Collectors.toList()); + } } catch (IOException ioe) { throw new IllegalStateException(ioe); } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/PageRankVertexProgramStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/PageRankVertexProgramStep.java index 2f67aeb6d70..dab1b9eb946 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/PageRankVertexProgramStep.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/PageRankVertexProgramStep.java @@ -53,7 +53,7 @@ public final class PageRankVertexProgramStep extends VertexProgramStep implement public PageRankVertexProgramStep(final Traversal.Admin traversal, final double alpha) { super(traversal); this.alpha = alpha; - this.modulateBy(__.outE().asAdmin()); + this.modulateBy(__.outE().asAdmin()); } @Override diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/PeerPressureVertexProgramStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/PeerPressureVertexProgramStep.java index 47d416058db..f6563961d59 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/PeerPressureVertexProgramStep.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/PeerPressureVertexProgramStep.java @@ -51,7 +51,7 @@ public final class PeerPressureVertexProgramStep extends VertexProgramStep imple public PeerPressureVertexProgramStep(final Traversal.Admin traversal) { super(traversal); - this.modulateBy(__.outE().asAdmin()); + this.modulateBy(__.outE().asAdmin()); } @Override diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/finalization/ComputerFinalizationStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/finalization/ComputerFinalizationStrategy.java index cbf4be51555..8fc47e3a774 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/finalization/ComputerFinalizationStrategy.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/finalization/ComputerFinalizationStrategy.java @@ -33,7 +33,8 @@ /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public final class ComputerFinalizationStrategy extends AbstractTraversalStrategy { +public final class ComputerFinalizationStrategy extends AbstractTraversalStrategy + implements TraversalStrategy.FinalizationStrategy { private static final ComputerFinalizationStrategy INSTANCE = new ComputerFinalizationStrategy(); diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/optimization/GraphFilterStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/optimization/GraphFilterStrategy.java index c32777bfc18..5e3657a2522 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/optimization/GraphFilterStrategy.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/optimization/GraphFilterStrategy.java @@ -109,18 +109,18 @@ protected static Traversal.Admin getEdgeFilter(final Traversal.Adm } // construct edges(...) if (outLabels.isEmpty() && inLabels.isEmpty() && bothLabels.isEmpty()) // out/in/both are never called, thus, filter all edges - return __.bothE().limit(0).asAdmin(); + return __.bothE().limit(0).asAdmin(); else { final String[] ins = inLabels.contains(null) ? new String[]{} : inLabels.toArray(new String[inLabels.size()]); final String[] outs = outLabels.contains(null) ? new String[]{} : outLabels.toArray(new String[outLabels.size()]); final String[] boths = bothLabels.contains(null) ? new String[]{} : bothLabels.toArray(new String[bothLabels.size()]); if (outLabels.isEmpty() && inLabels.isEmpty()) // only both has labels - return __.bothE(boths).asAdmin(); + return __.bothE(boths).asAdmin(); else if (inLabels.isEmpty() && bothLabels.isEmpty()) // only out has labels - return __.outE(outs).asAdmin(); + return __.outE(outs).asAdmin(); else if (outLabels.isEmpty() && bothLabels.isEmpty()) // only in has labels - return __.inE(ins).asAdmin(); + return __.inE(ins).asAdmin(); else if (bothLabels.isEmpty()) // out and in both have labels return __.union(__.inE(ins), __.outE(outs)).asAdmin(); else if (outLabels.isEmpty() && ins.length > 0) // in and both have labels (and in is not null) diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/ComputerGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/ComputerGraph.java index 31438c3e919..09c23539e9b 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/ComputerGraph.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/util/ComputerGraph.java @@ -325,7 +325,7 @@ public String key() { @Override public V value() throws NoSuchElementException { - return this.getBaseVertexProperty().value(); + return this.getBaseVertexProperty().value(); } @Override diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategy.java index 03c31abe826..8764d6cd2d8 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategy.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategy.java @@ -43,7 +43,7 @@ * @author Marko A. Rodriguez (http://markorodriguez.com) * @author Matthias Broecheler (me@matthiasb.com) */ -public interface TraversalStrategy extends Serializable, Comparable> { +public interface TraversalStrategy extends Serializable, Comparable> { public static final String STRATEGY = "strategy"; @@ -88,35 +88,52 @@ public default Configuration getConfiguration() { return new BaseConfiguration(); } - @Override - public default int compareTo(final Class otherTraversalCategory) { + /** + * Returns the "weight" of the class of this TraversalStrategy, used in {@link #compareTo}. It is recommended that + * this method returns a constant, i. e. the same value for all instances of some specific TraversalStrategy + * implementation class. Pre-defined "traversal categories" have specified "weights": {@link + * DecorationStrategy#COMPARISON_WEIGHT}, {@link OptimizationStrategy#COMPARISON_WEIGHT}, {@link + * ProviderOptimizationStrategy#COMPARISON_WEIGHT}, {@link FinalizationStrategy#COMPARISON_WEIGHT} and {@link + * VerificationStrategy#COMPARISON_WEIGHT}. + * + * The default implementation of this method returns 0. + */ + public default int getComparisonWeight() { return 0; } + /** + * TraversalStrategies are compared by their class, i. e. strategy1.compareTo(strategy2) always returns results of + * the same sign, when strategy1 and strategy2 are any instances of some specific implementation classes of + * TraversalStrategy. When strategy1 and strategy2 have the same class, strategy1.compareTo(strategy2) returns 0. + *

+ * This method is implemented as {@code + * Integer.compare(this.getComparisonWeight(), otherTraversalCategory.getComparisonWeight())}, and it is not + * recommended to override this implementation, {@link #getComparisonWeight()} should be overridden instead. + */ + @Override + public default int compareTo(final TraversalStrategy otherTraversalCategory) { + return Integer.compare(getComparisonWeight(), otherTraversalCategory.getComparisonWeight()); + } + /** * Implemented by strategies that adds "application logic" to the traversal (e.g. {@link PartitionStrategy}). */ public interface DecorationStrategy extends TraversalStrategy { + public static final int COMPARISON_WEIGHT = 100; + @Override public default Class getTraversalCategory() { return DecorationStrategy.class; } + /** + * Returns {@link #COMPARISON_WEIGHT}. It's not recommended to override this method. + */ @Override - public default int compareTo(final Class otherTraversalCategory) { - if (otherTraversalCategory.equals(DecorationStrategy.class)) - return 0; - else if (otherTraversalCategory.equals(OptimizationStrategy.class)) - return -1; - else if (otherTraversalCategory.equals(ProviderOptimizationStrategy.class)) - return -1; - else if (otherTraversalCategory.equals(FinalizationStrategy.class)) - return -1; - else if (otherTraversalCategory.equals(VerificationStrategy.class)) - return -1; - else - return 0; + default int getComparisonWeight() { + return COMPARISON_WEIGHT; } } @@ -127,25 +144,19 @@ else if (otherTraversalCategory.equals(VerificationStrategy.class)) */ public interface OptimizationStrategy extends TraversalStrategy { + public static final int COMPARISON_WEIGHT = 200; + @Override public default Class getTraversalCategory() { return OptimizationStrategy.class; } + /** + * Returns {@link #COMPARISON_WEIGHT}. It's not recommended to override this method. + */ @Override - public default int compareTo(final Class otherTraversalCategory) { - if (otherTraversalCategory.equals(DecorationStrategy.class)) - return 1; - else if (otherTraversalCategory.equals(OptimizationStrategy.class)) - return 0; - else if (otherTraversalCategory.equals(ProviderOptimizationStrategy.class)) - return -1; - else if (otherTraversalCategory.equals(FinalizationStrategy.class)) - return -1; - else if (otherTraversalCategory.equals(VerificationStrategy.class)) - return -1; - else - return 0; + default int getComparisonWeight() { + return COMPARISON_WEIGHT; } } @@ -155,25 +166,19 @@ else if (otherTraversalCategory.equals(VerificationStrategy.class)) */ public interface ProviderOptimizationStrategy extends TraversalStrategy { + public static final int COMPARISON_WEIGHT = 300; + @Override public default Class getTraversalCategory() { return ProviderOptimizationStrategy.class; } + /** + * Returns {@link #COMPARISON_WEIGHT}. It's not recommended to override this method. + */ @Override - public default int compareTo(final Class otherTraversalCategory) { - if (otherTraversalCategory.equals(DecorationStrategy.class)) - return 1; - else if (otherTraversalCategory.equals(OptimizationStrategy.class)) - return 1; - else if (otherTraversalCategory.equals(ProviderOptimizationStrategy.class)) - return 0; - else if (otherTraversalCategory.equals(FinalizationStrategy.class)) - return -1; - else if (otherTraversalCategory.equals(VerificationStrategy.class)) - return -1; - else - return 0; + default int getComparisonWeight() { + return COMPARISON_WEIGHT; } } @@ -183,25 +188,19 @@ else if (otherTraversalCategory.equals(VerificationStrategy.class)) */ public interface FinalizationStrategy extends TraversalStrategy { + public static final int COMPARISON_WEIGHT = 400; + @Override public default Class getTraversalCategory() { return FinalizationStrategy.class; } + /** + * Returns {@link #COMPARISON_WEIGHT}. It's not recommended to override this method. + */ @Override - public default int compareTo(final Class otherTraversalCategory) { - if (otherTraversalCategory.equals(DecorationStrategy.class)) - return 1; - else if (otherTraversalCategory.equals(OptimizationStrategy.class)) - return 1; - else if (otherTraversalCategory.equals(ProviderOptimizationStrategy.class)) - return 1; - else if (otherTraversalCategory.equals(FinalizationStrategy.class)) - return 0; - else if (otherTraversalCategory.equals(VerificationStrategy.class)) - return -1; - else - return 0; + default int getComparisonWeight() { + return COMPARISON_WEIGHT; } } @@ -212,23 +211,19 @@ else if (otherTraversalCategory.equals(VerificationStrategy.class)) */ public interface VerificationStrategy extends TraversalStrategy { + public static final int COMPARISON_WEIGHT = 500; + @Override public default Class getTraversalCategory() { return VerificationStrategy.class; } + /** + * Returns {@link #COMPARISON_WEIGHT}. It's not recommended to override this method. + */ @Override - public default int compareTo(final Class otherTraversalCategory) { - if (otherTraversalCategory.equals(DecorationStrategy.class)) - return 1; - else if (otherTraversalCategory.equals(OptimizationStrategy.class)) - return 1; - else if (otherTraversalCategory.equals(ProviderOptimizationStrategy.class)) - return 1; - else if (otherTraversalCategory.equals(FinalizationStrategy.class)) - return 1; - else - return 0; + default int getComparisonWeight() { + return COMPARISON_WEIGHT; } } } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java index ae0bd8e70f5..83864b27d54 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java @@ -47,7 +47,7 @@ public final class DefaultTraversalMetrics implements TraversalMetrics, Serializ /** * toString() specific headers */ - private static final String[] HEADERS = {"Step", "Count", "Traversers", "Time (ms)", "% Dur"}; + private static final Object[] HEADERS = {"Step", "Count", "Traversers", "Time (ms)", "% Dur"}; /** * {@link ImmutableMetrics} indexed by their step identifier. diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java index 056d3c82556..bf66407d428 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java @@ -178,7 +178,10 @@ public Vertex readVertex(final InputStream inputStream, // what it should have been anyway) stargraph format can remain unchanged across all versions final Map vertexData = mapper.readValue(inputStream, version == GraphSONVersion.V3_0 ? linkedHashMapTypeReference : mapTypeReference); final StarGraph starGraph = StarGraphGraphSONDeserializer.readStarGraphVertex(vertexData); - if (vertexAttachMethod != null) vertexAttachMethod.apply(starGraph.getStarVertex()); + if (vertexAttachMethod != null) { + @SuppressWarnings("unused") + Vertex ignored = vertexAttachMethod.apply(starGraph.getStarVertex()); + } if (vertexData.containsKey(GraphSONTokens.OUT_E) && (attachEdgesOfThisDirection == Direction.BOTH || attachEdgesOfThisDirection == Direction.OUT)) StarGraphGraphSONDeserializer.readStarGraphEdges(edgeAttachMethod, starGraph, vertexData, GraphSONTokens.OUT_E); diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java index ca4764da840..cecb8966ee1 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java @@ -279,7 +279,7 @@ else if (p.getValue1() instanceof Function) else throw new IllegalStateException(String.format( "Unexpected value provided by %s for serializable class %s - expected a parameter in [null, %s implementation or Function<%s, %s>], but received %s", - registry.getClass().getSimpleName(), p.getValue0().getClass().getCanonicalName(), + registry.getClass().getSimpleName(), p.getValue0().getCanonicalName(), Serializer.class.getName(), Kryo.class.getSimpleName(), Serializer.class.getSimpleName(), p.getValue1())); }); diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java index d9e9d7ba6eb..94cd3d2bc96 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java @@ -254,7 +254,10 @@ private Vertex readVertexInternal(final Function, Vertex> ver final Vertex v = vertexMaker.apply(starGraph.getStarVertex()); if (edgeMaker != null) - starGraph.getStarVertex().edges(d).forEachRemaining(e -> edgeMaker.apply((Attachable) e)); + starGraph.getStarVertex().edges(d).forEachRemaining(e -> { + @SuppressWarnings("unused") + Edge ignored = edgeMaker.apply((Attachable) e); + }); return v; } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphGraphSONDeserializer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphGraphSONDeserializer.java index 84a3fd40ea8..ada93db1371 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphGraphSONDeserializer.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphGraphSONDeserializer.java @@ -58,7 +58,10 @@ public static void readStarGraphEdges(final Function, Edge> edg } } - if (edgeMaker != null) edgeMaker.apply(starEdge); + if (edgeMaker != null) { + @SuppressWarnings("unused") + Edge ignored = edgeMaker.apply(starEdge); + } } } } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TimeUtil.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TimeUtil.java index 8932e42339e..b0ee3317a17 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TimeUtil.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TimeUtil.java @@ -70,7 +70,8 @@ public static Pair clockWithResult(final int loops, final Supplie final S result = supplier.get(); // warm up return Pair.with(IntStream.range(0, loops).mapToDouble(i -> { long t = System.nanoTime(); - supplier.get(); + @SuppressWarnings("unused") + final S ignored = supplier.get(); return (System.nanoTime() - t) * 0.000001; }).sum() / loops, result); } diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilterTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilterTest.java index 0420f60b72e..953bac5f7ec 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilterTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilterTest.java @@ -40,7 +40,9 @@ public class GraphFilterTest { @Test public void shouldHaveValidLegalEnumOrdering() { - assertTrue(GraphFilter.Legal.YES.compareTo(GraphFilter.Legal.YES) == 0); + @SuppressWarnings({"SelfComparison", "EqualsWithItself"}) + int selfComparisonResult = GraphFilter.Legal.YES.compareTo(GraphFilter.Legal.YES); + assertEquals(0, selfComparisonResult); assertTrue(GraphFilter.Legal.YES.compareTo(GraphFilter.Legal.NO) < 0); assertTrue(GraphFilter.Legal.YES.compareTo(GraphFilter.Legal.MAYBE) < 0); assertTrue(GraphFilter.Legal.MAYBE.compareTo(GraphFilter.Legal.NO) < 0); @@ -51,10 +53,10 @@ public void shouldOnlyAllowEdgeFilterToTraverseLocalStarGraph() { GraphFilter graphFilter = new GraphFilter(); graphFilter.setEdgeFilter(__.outE()); try { - graphFilter.setEdgeFilter(__.outE().inV().outE()); + graphFilter.setEdgeFilter(__.outE().inV().outE()); fail("Should not allow traversals past the star graph"); } catch (final IllegalArgumentException e) { - assertEquals(e.getMessage(), GraphComputer.Exceptions.edgeFilterAccessesAdjacentVertices(__.outE().inV().outE()).getMessage()); + assertEquals(e.getMessage(), GraphComputer.Exceptions.edgeFilterAccessesAdjacentVertices(__.outE().inV().outE()).getMessage()); } } @@ -93,7 +95,7 @@ public void shouldGetLegallyPositiveEdgeLabels() { assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH)); // graphFilter = new GraphFilter(); - graphFilter.setEdgeFilter(__.outE("created").has("weight", 32)); + graphFilter.setEdgeFilter(__.outE("created").has("weight", 32)); assertTrue(graphFilter.hasEdgeFilter()); assertEquals(Collections.singleton("created"), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT)); assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN)); @@ -114,21 +116,21 @@ public void shouldGetLegallyPositiveEdgeLabels() { assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH)); // graphFilter = new GraphFilter(); - graphFilter.setEdgeFilter(__.bothE().has("weight", 32)); + graphFilter.setEdgeFilter(__.bothE().has("weight", 32)); assertTrue(graphFilter.hasEdgeFilter()); assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT)); assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN)); assertEquals(Collections.singleton(null), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH)); // graphFilter = new GraphFilter(); - graphFilter.setEdgeFilter(__.bothE().limit(0)); + graphFilter.setEdgeFilter(__.bothE().limit(0)); assertTrue(graphFilter.hasEdgeFilter()); assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT)); assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN)); assertEquals(Collections.emptySet(), graphFilter.getLegallyPositiveEdgeLabels(Direction.BOTH)); // graphFilter = new GraphFilter(); - graphFilter.setEdgeFilter(__.bothE("created").has("weight", 32)); + graphFilter.setEdgeFilter(__.bothE("created").has("weight", 32)); assertTrue(graphFilter.hasEdgeFilter()); assertEquals(Collections.singleton("created"), graphFilter.getLegallyPositiveEdgeLabels(Direction.OUT)); assertEquals(Collections.singleton("created"), graphFilter.getLegallyPositiveEdgeLabels(Direction.IN)); @@ -181,7 +183,7 @@ public void shouldHaveProperEdgeLegality() { assertEquals(GraphFilter.Legal.MAYBE, graphFilter.checkEdgeLegality(Direction.OUT, "knows")); // graphFilter = new GraphFilter(); - graphFilter.setEdgeFilter(__.bothE().has("weight", 32)); + graphFilter.setEdgeFilter(__.bothE().has("weight", 32)); assertTrue(graphFilter.hasEdgeFilter()); assertEquals(GraphFilter.Legal.MAYBE, graphFilter.checkEdgeLegality(Direction.IN)); assertEquals(GraphFilter.Legal.MAYBE, graphFilter.checkEdgeLegality(Direction.BOTH)); @@ -191,7 +193,7 @@ public void shouldHaveProperEdgeLegality() { assertEquals(GraphFilter.Legal.MAYBE, graphFilter.checkEdgeLegality(Direction.OUT, "knows")); // graphFilter = new GraphFilter(); - graphFilter.setEdgeFilter(__.inE().has("weight", 32)); + graphFilter.setEdgeFilter(__.inE().has("weight", 32)); assertTrue(graphFilter.hasEdgeFilter()); assertEquals(GraphFilter.Legal.MAYBE, graphFilter.checkEdgeLegality(Direction.IN)); assertEquals(GraphFilter.Legal.NO, graphFilter.checkEdgeLegality(Direction.BOTH)); @@ -201,7 +203,7 @@ public void shouldHaveProperEdgeLegality() { assertEquals(GraphFilter.Legal.NO, graphFilter.checkEdgeLegality(Direction.OUT, "knows")); // graphFilter = new GraphFilter(); - graphFilter.setEdgeFilter(__.bothE().limit(0)); + graphFilter.setEdgeFilter(__.bothE().limit(0)); assertTrue(graphFilter.hasEdgeFilter()); assertEquals(GraphFilter.Legal.NO, graphFilter.checkEdgeLegality(Direction.IN)); assertEquals(GraphFilter.Legal.NO, graphFilter.checkEdgeLegality(Direction.BOTH)); @@ -216,7 +218,7 @@ public void shouldHaveProperEdgeLegality() { assertEquals(GraphFilter.Legal.YES, graphFilter.checkEdgeLegality(Direction.OUT, "knows")); // graphFilter = new GraphFilter(); - graphFilter.setEdgeFilter(__.outE().limit(10)); + graphFilter.setEdgeFilter(__.outE().limit(10)); assertTrue(graphFilter.hasEdgeFilter()); assertEquals(GraphFilter.Legal.NO, graphFilter.checkEdgeLegality(Direction.IN)); assertEquals(GraphFilter.Legal.NO, graphFilter.checkEdgeLegality(Direction.BOTH)); @@ -224,7 +226,7 @@ public void shouldHaveProperEdgeLegality() { assertEquals(GraphFilter.Legal.MAYBE, graphFilter.checkEdgeLegality(Direction.OUT, "knows")); // graphFilter = new GraphFilter(); - graphFilter.setEdgeFilter(__.outE("knows").limit(10)); + graphFilter.setEdgeFilter(__.outE("knows").limit(10)); assertTrue(graphFilter.hasEdgeFilter()); assertEquals(GraphFilter.Legal.NO, graphFilter.checkEdgeLegality(Direction.IN)); assertEquals(GraphFilter.Legal.NO, graphFilter.checkEdgeLegality(Direction.BOTH)); diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/OperatorExceptionTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/OperatorExceptionTest.java index 9aa1339684f..72879cff49d 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/OperatorExceptionTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/OperatorExceptionTest.java @@ -27,31 +27,37 @@ public class OperatorExceptionTest { @Test(expected = ClassCastException.class) public void shouldThrowIfValueToDivIsNotNumeric() { - Operator.div.apply("1", "1"); + @SuppressWarnings("unused") + Object ignore = Operator.div.apply("1", "1"); } @Test(expected = ClassCastException.class) public void shouldThrowIfValueToMaxIsNotNumeric() { - Operator.max.apply("1", "1"); + @SuppressWarnings("unused") + Object ignore = Operator.max.apply("1", "1"); } @Test(expected = ClassCastException.class) public void shouldThrowIfValueToMinIsNotNumeric() { - Operator.min.apply("1", "1"); + @SuppressWarnings("unused") + Object ignore = Operator.min.apply("1", "1"); } @Test(expected = ClassCastException.class) public void shouldThrowIfValueToMinusIsNotNumeric() { - Operator.minus.apply("1", "1"); + @SuppressWarnings("unused") + Object ignore = Operator.minus.apply("1", "1"); } @Test(expected = ClassCastException.class) public void shouldThrowIfValueToMultIsNotNumeric() { - Operator.mult.apply("1", "1"); + @SuppressWarnings("unused") + Object ignore = Operator.mult.apply("1", "1"); } @Test(expected = ClassCastException.class) public void shouldThrowIfValueToSumIsNotNumeric() { - Operator.sum.apply("1", "1"); + @SuppressWarnings("unused") + Object ignore = Operator.sum.apply("1", "1"); } } diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategyTest.java index 901d3a5da86..40635dfdb92 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategyTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategyTest.java @@ -33,7 +33,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.StandardVerificationStrategy; import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies; import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; -import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.VertexProperty; import org.hamcrest.CoreMatchers; import org.junit.Test; @@ -141,7 +140,7 @@ public void shouldAddBothFiltersAfterVertex() { @Test public void shouldNotRetainMarkers() { - final SubgraphStrategy strategy = SubgraphStrategy.build().vertices(__.out().hasLabel("person")).create(); + final SubgraphStrategy strategy = SubgraphStrategy.build().vertices(__.out().hasLabel("person")).create(); final Traversal.Admin t = out().inE().asAdmin(); t.setStrategies(t.getStrategies().clone().addStrategies(strategy, StandardVerificationStrategy.instance())); t.applyStrategies(); diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RepeatUnrollStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RepeatUnrollStrategyTest.java index 88eb5a694ec..5cbbe57d205 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RepeatUnrollStrategyTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RepeatUnrollStrategyTest.java @@ -82,7 +82,7 @@ public static Iterable generateTestParameters() { {__.repeat(out()).times(3), out().barrier(maxBarrierSize).out().barrier(maxBarrierSize).out().barrier(maxBarrierSize), Collections.emptyList()}, {__.repeat(__.local(__.select("a").out("knows"))).times(2), __.local(__.select("a").out("knows")).barrier(maxBarrierSize).local(__.select("a").out("knows")).barrier(maxBarrierSize), Collections.emptyList()}, {__.times(2).repeat(out()), out().barrier(maxBarrierSize).out().barrier(maxBarrierSize), Collections.emptyList()}, - {__.out().times(2).repeat(out().as("a")).as("x"), out().out().as("a").barrier(maxBarrierSize).out().as("a").barrier(maxBarrierSize).as("x"), Collections.emptyList()}, + {__.out().times(2).repeat(out().as("a")).as("x"), out().out().as("a").barrier(maxBarrierSize).out().as("a").barrier(maxBarrierSize).as("x"), Collections.emptyList()}, {__.repeat(out()).emit().times(2), __.repeat(out()).emit().times(2), Collections.emptyList()}, {__.repeat(out()).until(predicate), __.repeat(out()).until(predicate), Collections.emptyList()}, {__.repeat(out()).until(predicate).repeat(out()).times(2), __.repeat(out()).until(predicate).out().barrier(maxBarrierSize).out().barrier(maxBarrierSize), Collections.emptyList()}, diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/FunctionUtilsTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/FunctionUtilsTest.java index 2679fd1efbf..f37d8654985 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/FunctionUtilsTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/FunctionUtilsTest.java @@ -19,7 +19,6 @@ package org.apache.tinkerpop.gremlin.util.function; import org.apache.tinkerpop.gremlin.TestHelper; -import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; import org.junit.Test; import static org.hamcrest.CoreMatchers.instanceOf; @@ -41,7 +40,8 @@ public void shouldBeUtilityClass() throws Exception { public void shouldWrapInRuntimeIfFunctionThrows() { final Exception t = new Exception(); try { - FunctionUtils.wrapFunction(FunctionUtilsTest::throwIt).apply(t); + @SuppressWarnings("unused") + Integer ignore = FunctionUtils.wrapFunction(FunctionUtilsTest::throwIt).apply(t); } catch (Exception ex) { assertThat(ex, instanceOf(RuntimeException.class)); assertSame(t, ex.getCause()); @@ -52,7 +52,8 @@ public void shouldWrapInRuntimeIfFunctionThrows() { public void shouldNoReWrapInRuntimeIfFunctionThrows() { final Exception t = new RuntimeException(); try { - FunctionUtils.wrapFunction(FunctionUtilsTest::throwIt).apply(t); + @SuppressWarnings("unused") + Integer ignore = FunctionUtils.wrapFunction(FunctionUtilsTest::throwIt).apply(t); } catch (Exception ex) { assertThat(ex, instanceOf(RuntimeException.class)); assertNull(ex.getCause()); @@ -115,7 +116,8 @@ public void shouldNoReWrapInRuntimeIfBiConsumerThrows() { public void shouldWrapInRuntimeIfSupplierThrows() { final Exception t = new Exception(); try { - FunctionUtils.wrapSupplier(() -> { + @SuppressWarnings("unused") + Object ignore = FunctionUtils.wrapSupplier(() -> { throw t; }).get(); } catch (Exception ex) { @@ -128,7 +130,8 @@ public void shouldWrapInRuntimeIfSupplierThrows() { public void shouldNoReWrapInRuntimeIfSupplierThrows() { final Exception t = new RuntimeException(); try { - FunctionUtils.wrapSupplier(() -> { + @SuppressWarnings("unused") + Object ignore = FunctionUtils.wrapSupplier(() -> { throw t; }).get(); } catch (Exception ex) { diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java index e21e265617b..09eb5d4a7bf 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java @@ -130,7 +130,7 @@ public void addSideEffect(final String aggregateTo, final Object sideEffectValue private V validate(final String aggregateTo, final Class expected) { if (!(expected.isAssignableFrom(aggregatedResult.getClass()))) throw new IllegalStateException(String.format("Side-effect \"%s\" contains the type %s that is not acceptable for %s", - aggregatedResult.getClass().getSimpleName(), aggregateTo)); + aggregatedResult.getClass().getSimpleName(), expected.getSimpleName(), aggregateTo)); return (V) aggregatedResult; } diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java index 21969cad901..4802f0667b2 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java @@ -1740,7 +1740,7 @@ public void shouldSupportGraphFilter() throws Exception { assertEquals(GraphComputer.Exceptions.graphFilterNotSupported().getMessage(), e.getMessage()); } try { - graphProvider.getGraphComputer(graph).edges(__.outE().limit(10)); + graphProvider.getGraphComputer(graph).edges(__.outE().limit(10)); fail("Should throw an unsupported operation exception"); } catch (final UnsupportedOperationException e) { assertEquals(GraphComputer.Exceptions.graphFilterNotSupported().getMessage(), e.getMessage()); @@ -1752,9 +1752,9 @@ public void shouldSupportGraphFilter() throws Exception { graphProvider.getGraphComputer(graph).vertices(__.hasLabel("person")).program(new VertexProgramM(VertexProgramM.PEOPLE_ONLY)).submit().get(); graphProvider.getGraphComputer(graph).edges(__.bothE("knows")).program(new VertexProgramM(VertexProgramM.KNOWS_ONLY)).submit().get(); graphProvider.getGraphComputer(graph).vertices(__.hasLabel("person")).edges(__.bothE("knows")).program(new VertexProgramM(VertexProgramM.PEOPLE_KNOWS_ONLY)).submit().get(); - graphProvider.getGraphComputer(graph).vertices(__.hasLabel("person")).edges(__.bothE("knows").has("weight", P.gt(0.5f))).program(new VertexProgramM(VertexProgramM.PEOPLE_KNOWS_WELL_ONLY)).submit().get(); - graphProvider.getGraphComputer(graph).edges(__.bothE().limit(0)).program(new VertexProgramM(VertexProgramM.VERTICES_ONLY)).submit().get(); - graphProvider.getGraphComputer(graph).edges(__.outE().limit(1)).program(new VertexProgramM(VertexProgramM.ONE_OUT_EDGE_ONLY)).submit().get(); + graphProvider.getGraphComputer(graph).vertices(__.hasLabel("person")).edges(__.bothE("knows").has("weight", P.gt(0.5f))).program(new VertexProgramM(VertexProgramM.PEOPLE_KNOWS_WELL_ONLY)).submit().get(); + graphProvider.getGraphComputer(graph).edges(__.bothE().limit(0)).program(new VertexProgramM(VertexProgramM.VERTICES_ONLY)).submit().get(); + graphProvider.getGraphComputer(graph).edges(__.outE().limit(1)).program(new VertexProgramM(VertexProgramM.ONE_OUT_EDGE_ONLY)).submit().get(); graphProvider.getGraphComputer(graph).edges(outE()).program(new VertexProgramM(VertexProgramM.OUT_EDGES_ONLY)).submit().get(); /// VERTEX PROGRAM + MAP REDUCE @@ -1762,9 +1762,9 @@ public void shouldSupportGraphFilter() throws Exception { graphProvider.getGraphComputer(graph).vertices(__.hasLabel("person")).program(new VertexProgramM(VertexProgramM.PEOPLE_ONLY)).mapReduce(new MapReduceJ(VertexProgramM.PEOPLE_ONLY)).submit().get(); graphProvider.getGraphComputer(graph).edges(__.bothE("knows")).program(new VertexProgramM(VertexProgramM.KNOWS_ONLY)).mapReduce(new MapReduceJ(VertexProgramM.KNOWS_ONLY)).submit().get(); graphProvider.getGraphComputer(graph).vertices(__.hasLabel("person")).edges(__.bothE("knows")).program(new VertexProgramM(VertexProgramM.PEOPLE_KNOWS_ONLY)).mapReduce(new MapReduceJ(VertexProgramM.PEOPLE_KNOWS_ONLY)).submit().get(); - graphProvider.getGraphComputer(graph).vertices(__.hasLabel("person")).edges(__.bothE("knows").has("weight", P.gt(0.5f))).program(new VertexProgramM(VertexProgramM.PEOPLE_KNOWS_WELL_ONLY)).mapReduce(new MapReduceJ(VertexProgramM.PEOPLE_KNOWS_WELL_ONLY)).submit().get(); - graphProvider.getGraphComputer(graph).edges(__.bothE().limit(0)).program(new VertexProgramM(VertexProgramM.VERTICES_ONLY)).mapReduce(new MapReduceJ(VertexProgramM.VERTICES_ONLY)).submit().get(); - graphProvider.getGraphComputer(graph).edges(__.outE().limit(1)).program(new VertexProgramM(VertexProgramM.ONE_OUT_EDGE_ONLY)).mapReduce(new MapReduceJ(VertexProgramM.ONE_OUT_EDGE_ONLY)).submit().get(); + graphProvider.getGraphComputer(graph).vertices(__.hasLabel("person")).edges(__.bothE("knows").has("weight", P.gt(0.5f))).program(new VertexProgramM(VertexProgramM.PEOPLE_KNOWS_WELL_ONLY)).mapReduce(new MapReduceJ(VertexProgramM.PEOPLE_KNOWS_WELL_ONLY)).submit().get(); + graphProvider.getGraphComputer(graph).edges(__.bothE().limit(0)).program(new VertexProgramM(VertexProgramM.VERTICES_ONLY)).mapReduce(new MapReduceJ(VertexProgramM.VERTICES_ONLY)).submit().get(); + graphProvider.getGraphComputer(graph).edges(__.outE().limit(1)).program(new VertexProgramM(VertexProgramM.ONE_OUT_EDGE_ONLY)).mapReduce(new MapReduceJ(VertexProgramM.ONE_OUT_EDGE_ONLY)).submit().get(); graphProvider.getGraphComputer(graph).edges(outE()).program(new VertexProgramM(VertexProgramM.OUT_EDGES_ONLY)).mapReduce(new MapReduceJ(VertexProgramM.OUT_EDGES_ONLY)).submit().get(); /// MAP REDUCE ONLY @@ -1772,9 +1772,9 @@ public void shouldSupportGraphFilter() throws Exception { graphProvider.getGraphComputer(graph).vertices(__.hasLabel("person")).mapReduce(new MapReduceJ(VertexProgramM.PEOPLE_ONLY)).submit().get(); graphProvider.getGraphComputer(graph).edges(__.bothE("knows")).mapReduce(new MapReduceJ(VertexProgramM.KNOWS_ONLY)).submit().get(); graphProvider.getGraphComputer(graph).vertices(__.hasLabel("person")).edges(__.bothE("knows")).mapReduce(new MapReduceJ(VertexProgramM.PEOPLE_KNOWS_ONLY)).submit().get(); - graphProvider.getGraphComputer(graph).vertices(__.hasLabel("person")).edges(__.bothE("knows").has("weight", P.gt(0.5f))).mapReduce(new MapReduceJ(VertexProgramM.PEOPLE_KNOWS_WELL_ONLY)).submit().get(); - graphProvider.getGraphComputer(graph).edges(__.bothE().limit(0)).mapReduce(new MapReduceJ(VertexProgramM.VERTICES_ONLY)).submit().get(); - graphProvider.getGraphComputer(graph).edges(__.outE().limit(1)).mapReduce(new MapReduceJ(VertexProgramM.ONE_OUT_EDGE_ONLY)).submit().get(); + graphProvider.getGraphComputer(graph).vertices(__.hasLabel("person")).edges(__.bothE("knows").has("weight", P.gt(0.5f))).mapReduce(new MapReduceJ(VertexProgramM.PEOPLE_KNOWS_WELL_ONLY)).submit().get(); + graphProvider.getGraphComputer(graph).edges(__.bothE().limit(0)).mapReduce(new MapReduceJ(VertexProgramM.VERTICES_ONLY)).submit().get(); + graphProvider.getGraphComputer(graph).edges(__.outE().limit(1)).mapReduce(new MapReduceJ(VertexProgramM.ONE_OUT_EDGE_ONLY)).submit().get(); graphProvider.getGraphComputer(graph).edges(outE()).mapReduce(new MapReduceJ(VertexProgramM.OUT_EDGES_ONLY)).submit().get(); // EXCEPTION HANDLING @@ -1785,10 +1785,10 @@ public void shouldSupportGraphFilter() throws Exception { assertEquals(e.getMessage(), GraphComputer.Exceptions.vertexFilterAccessesIncidentEdges(__.out()).getMessage()); } try { - graphProvider.getGraphComputer(graph).edges(__.out().outE()); + graphProvider.getGraphComputer(graph).edges(__.out().outE()); fail(); } catch (final IllegalArgumentException e) { - assertEquals(e.getMessage(), GraphComputer.Exceptions.edgeFilterAccessesAdjacentVertices(__.out().outE()).getMessage()); + assertEquals(e.getMessage(), GraphComputer.Exceptions.edgeFilterAccessesAdjacentVertices(__.out().outE()).getMessage()); } } diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PathTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PathTest.java index 30149982933..808eea57f65 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PathTest.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PathTest.java @@ -70,7 +70,7 @@ public void g_VX1X_name_path() { final Path path = traversal.next(); assertFalse(traversal.hasNext()); assertEquals(2, path.size()); - assertEquals(convertToVertexId("marko"), ((Vertex) path.get(0)).id()); + assertEquals(convertToVertexId("marko"), ((Vertex) path.get(0)).id()); assertEquals("marko", path.get(1)); assertFalse(traversal.hasNext()); } diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupCountTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupCountTest.java index 34011acdf9f..0b17030e18e 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupCountTest.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupCountTest.java @@ -267,7 +267,7 @@ public Traversal> get_g_V_outXcreatedX_groupCount_byXn @Override public Traversal> get_g_V_outXcreatedX_groupCountXaX_byXnameX_capXaX() { - return g.V().out("created").groupCount("a").by("name").cap("a"); + return g.V().out("created").groupCount("a").by("name").cap("a"); } @Override diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java index 6a58aa725ce..1156b8ddd8e 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java @@ -497,7 +497,7 @@ public Traversal>> get_g_V_group_byXnameX @Override public Traversal>> get_g_V_groupXaX_byXnameX_capXaX() { - return g.V().>group("a").by("name").cap("a"); + return g.V().group("a").by("name").cap("a"); } @Override @@ -522,7 +522,7 @@ public Traversal>> get_g_V_group_byXoutE_co @Override public Traversal> get_g_V_groupXaX_byXlabelX_byXoutE_weight_sumX_capXaX() { - return g.V().group("a").by(T.label).by(outE().values("weight").sum()).cap("a"); + return g.V().group("a").by(T.label).by(outE().values("weight").sum()).cap("a"); } @Override @@ -532,7 +532,7 @@ public Traversal> get_g_V_repeatXbothXfollowedByXX_tim @Override public Traversal> get_g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX() { - return g.V().repeat(both("followedBy")).times(2).group("a").by("songType").by(count()).cap("a"); + return g.V().repeat(both("followedBy")).times(2).group("a").by("songType").by(count()).cap("a"); } @Override @@ -542,7 +542,7 @@ public Traversal> get_g_V_group_byXname_substring_1X_b @Override public Traversal> get_g_V_groupXaX_byXname_substring_1X_byXconstantX1XX_capXaX() { - return g.V().group("a").by(v -> v.value("name").substring(0, 1)).by(constant(1l)).cap("a"); + return g.V().group("a").by(v -> v.value("name").substring(0, 1)).by(constant(1l)).cap("a"); } @Override diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategyProcessTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategyProcessTest.java index 10473a8d611..5f5fb57878b 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategyProcessTest.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/SubgraphStrategyProcessTest.java @@ -237,14 +237,14 @@ public void shouldFilterEdgeCriterion() throws Exception { @Test @LoadGraphWith(MODERN) public void shouldFilterComplexVertexCriterion() throws Exception { - checkResults(Arrays.asList("vadas", "josh"), g.withStrategies(SubgraphStrategy.build().vertices(__.in("knows").has("name", "marko")).create()). + checkResults(Arrays.asList("vadas", "josh"), g.withStrategies(SubgraphStrategy.build().vertices(__.in("knows").has("name", "marko")).create()). V().values("name")); - checkResults(Arrays.asList("vadas", "josh", "lop"), g.withStrategies(SubgraphStrategy.build().vertices(__.in().has("name", "marko")).create()). + checkResults(Arrays.asList("vadas", "josh", "lop"), g.withStrategies(SubgraphStrategy.build().vertices(__.in().has("name", "marko")).create()). V().values("name")); - checkResults(Arrays.asList("vadas", "josh"), g.withStrategies(SubgraphStrategy.build().vertices(__.in("knows").where(out("created").has("name", "lop"))).create()). + checkResults(Arrays.asList("vadas", "josh"), g.withStrategies(SubgraphStrategy.build().vertices(__.in("knows").where(out("created").has("name", "lop"))).create()). V().values("name")); - checkResults(Arrays.asList("vadas", "josh", "lop"), g.withStrategies(SubgraphStrategy.build().vertices(__.in().where(has("name", "marko").out("created").has("name", "lop"))).create()). + checkResults(Arrays.asList("vadas", "josh", "lop"), g.withStrategies(SubgraphStrategy.build().vertices(__.in().where(has("name", "marko").out("created").has("name", "lop"))).create()). V().values("name")); checkResults(Arrays.asList("marko", "vadas", "josh", "lop"), g.withStrategies(SubgraphStrategy.build().vertices(__.or(both().has("name", "marko"), has("name", "marko"))).create()). diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/AbstractIoRegistryCheck.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/AbstractIoRegistryCheck.java index 8b89fc1456b..5d16689b766 100644 --- a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/AbstractIoRegistryCheck.java +++ b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/AbstractIoRegistryCheck.java @@ -130,8 +130,8 @@ private void validateIoRegistryGraph(final HadoopGraph graph, private void validatePointTriangles(final List> values) { assertEquals(NUMBER_OF_VERTICES, values.size()); for (int i = 0; i < NUMBER_OF_VERTICES; i++) { - assertTrue(values.stream().map(m -> m.get("point")).collect(Collectors.toList()).contains(new ToyPoint(i, i * 10))); - assertTrue(values.stream().map(m -> m.get("triangle")).collect(Collectors.toList()).contains(new ToyTriangle(i, i * 10, i * 100))); + assertTrue(values.stream().map(m -> m.get("point")).collect(Collectors.toList()).contains(new ToyPoint(i, i * 10))); + assertTrue(values.stream().map(m -> m.get("triangle")).collect(Collectors.toList()).contains(new ToyTriangle(i, i * 10, i * 100))); } } } diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritableTest.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritableTest.java index 12f4694c03c..ef10541997b 100644 --- a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritableTest.java +++ b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritableTest.java @@ -44,6 +44,8 @@ public void shouldNotHaveANullPointerException() { assertEquals(-1, new ObjectWritable<>("bloop").compareTo(object)); assertEquals(0, ObjectWritable.empty().compareTo(object)); assertEquals(0, object.compareTo(ObjectWritable.empty())); - assertEquals(0, object.compareTo(object)); + @SuppressWarnings({"SelfComparison", "EqualsWithItself"}) + int selfComparisonResult = object.compareTo(object); + assertEquals(0, selfComparisonResult); } } diff --git a/pom.xml b/pom.xml index a1abadee6bb..8344359de96 100644 --- a/pom.xml +++ b/pom.xml @@ -174,6 +174,22 @@ limitations under the License. org.apache.maven.plugins maven-compiler-plugin + + javac-with-errorprone + true + + + + org.codehaus.plexus + plexus-compiler-javac-errorprone + 2.8.3 + + + com.google.errorprone + error_prone_core + 2.2.0 + + maven-enforcer-plugin @@ -524,7 +540,7 @@ limitations under the License. org.apache.maven.plugins maven-shade-plugin - 3.0.0 + 3.1.0 org.apache.maven.plugins diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/TinkerGraphComputerView.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/TinkerGraphComputerView.java index 43998fb292c..0b6180d0c52 100644 --- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/TinkerGraphComputerView.java +++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/TinkerGraphComputerView.java @@ -222,7 +222,7 @@ private void addValue(final Vertex vertex, final String key, final VertexPropert } private void removeValue(final Vertex vertex, final String key, final VertexProperty property) { - this.computeProperties.>>>getOrDefault(vertex, Collections.emptyMap()).get(key).remove(property); + this.computeProperties.getOrDefault(vertex, Collections.emptyMap()).get(key).remove(property); } private List> getValue(final Vertex vertex, final String key) { diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIndex.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIndex.java index f5872cf0d56..05f2e962479 100644 --- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIndex.java +++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIndex.java @@ -133,8 +133,8 @@ public void createKeyIndex(final String key) { this.indexedKeys.add(key); (Vertex.class.isAssignableFrom(this.indexClass) ? - this.graph.vertices.values().parallelStream() : - this.graph.edges.values().parallelStream()) + this.graph.vertices.values().parallelStream() : + this.graph.edges.values().parallelStream()) .map(e -> new Object[]{((T) e).property(key), e}) .filter(a -> ((Property) a[0]).isPresent()) .forEach(a -> this.put(key, ((Property) a[0]).value(), (T) a[1]));