Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1743 [created] 1e04d928a


Fixed a lambda-leak in SackValueStep where BiFunction could be a real lambda.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/1e04d928
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/1e04d928
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/1e04d928

Branch: refs/heads/TINKERPOP-1743
Commit: 1e04d928a0b87f6aa82e77756f5458d62b14a6d9
Parents: 3c75dd0
Author: Marko A. Rodriguez <okramma...@gmail.com>
Authored: Tue Aug 8 10:12:11 2017 -0600
Committer: Marko A. Rodriguez <okramma...@gmail.com>
Committed: Tue Aug 8 10:12:11 2017 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                               | 1 +
 .../gremlin/process/traversal/step/sideEffect/SackValueStep.java | 4 ++++
 .../strategy/verification/LambdaRestrictionStrategy.java         | 3 +++
 .../strategy/verification/LambdaRestrictionStrategyTest.java     | 4 ++++
 4 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1e04d928/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 803f3b2..767ba09 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -28,6 +28,7 @@ TinkerPop 3.2.6 (Release Date: NOT OFFICIALLY RELEASED YET)
 
 This release also includes changes from <<release-3-1-8, 3.1.8>>.
 
+* Fixed a lambda-leak in `SackValueStep` where `BiFunction` must be tested for 
true lambda status.
 * Allowed access to `InjectStep.injections` for `TraversalStrategy` analysis.
 * Exceptions that occur during result iteration in Gremlin Server will now 
return `SCRIPT_EVALUATION_EXCEPTION` rather than `SERVER_ERROR`.
 * `AddEdgeStep` attaches detached vertices prior to edge creation.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1e04d928/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackValueStep.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackValueStep.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackValueStep.java
index 7f030d6..3281fa7 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackValueStep.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackValueStep.java
@@ -70,6 +70,10 @@ public final class SackValueStep<S, A, B> extends 
SideEffectStep<S> implements T
         return super.hashCode() ^ this.sackFunction.hashCode() ^ ((null == 
this.sackTraversal) ? "null".hashCode() : this.sackTraversal.hashCode());
     }
 
+    public BiFunction<A,B,A> getSackFunction() {
+        return this.sackFunction;
+    }
+
     @Override
     public Set<TraverserRequirement> getRequirements() {
         return getSelfAndChildRequirements(TraverserRequirement.SACK);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1e04d928/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java
index 9828d61..1b925ca 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategy.java
@@ -23,6 +23,7 @@ import 
org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.ComparatorHolder;
 import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder;
+import 
org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SackValueStep;
 import 
org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
 import org.javatuples.Pair;
 
@@ -64,6 +65,8 @@ public final class LambdaRestrictionStrategy extends 
AbstractTraversalStrategy<T
                         throw new VerificationException("The provided step 
contains a lambda comparator: " + step, traversal);
                 }
             }
+            if (step instanceof SackValueStep && (((SackValueStep) 
step).getSackFunction().toString().contains("$$Lambda$")))
+                throw new VerificationException("The provided step contains a 
lambda comparator: " + step, traversal);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1e04d928/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategyTest.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategyTest.java
 
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategyTest.java
index 4efca84..9bb251c 100644
--- 
a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategyTest.java
+++ 
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/LambdaRestrictionStrategyTest.java
@@ -33,6 +33,7 @@ import org.junit.runners.Parameterized;
 
 import java.util.Arrays;
 
+import static org.apache.tinkerpop.gremlin.process.traversal.Operator.sum;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -59,6 +60,9 @@ public class LambdaRestrictionStrategyTest {
                 {"order(local).by(values,decr)", 
__.order(Scope.local).by(Column.values, Order.decr), true},
                 {"order().by(label,decr)", __.order().by(T.label, Order.decr), 
true},
                 {"groupCount().by(label)", __.groupCount().by(T.label), true},
+                //
+                {"sack(sum).by('age')", __.sack(sum).by("age"), true},
+                {"sack{a,b -> a+b}.by('age')", __.sack((a, b) -> (int) a + 
(int) b).by("age"), false},
         });
     }
 

Reply via email to