This is an automated email from the ASF dual-hosted git repository.
kenhuuu pushed a commit to branch 3.8-dev
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
The following commit(s) were added to refs/heads/3.8-dev by this push:
new 0516a7d5b8 TINKERPOP-3195 Prevent SupplyingBarrier Steps inside
RepeatStep
0516a7d5b8 is described below
commit 0516a7d5b8655346854ea162e0f6171a15e0281b
Author: Ken Hu <[email protected]>
AuthorDate: Fri Oct 3 16:28:26 2025 -0700
TINKERPOP-3195 Prevent SupplyingBarrier Steps inside RepeatStep
SideEfffectCapStep (currently the only SupplyingBarrier) doesn't work
inside repeat() and its semantics don't make sense either. It consumes
all the starts and can output any traverser which can lead to errors.
---
CHANGELOG.asciidoc | 1 +
docs/src/upgrade/release-3.8.x.asciidoc | 8 ++++++++
.../strategy/verification/StandardVerificationStrategy.java | 7 +++++--
.../strategy/verification/StandardVerificationStrategyTest.java | 2 ++
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index b959cab335..c403f01c7a 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -73,6 +73,7 @@ This release also includes changes from <<release-3-7-XXX,
3.7.XXX>>.
* Updated `ElementIdStrategy.getConfiguration()` to help with serialization.
* Fixed issue in `gremlin-go` where `Next()` didn't return the error from the
server.
* Changed type for `ReservedKeysVerificationStrategy.keys` in .NET to take a
`Set<string>` rather than `List<string>`.
+* Changed `StandardVerificationStrategy` to prevent the use of
`SupplyingBarriers` inside `repeat()`.
* Fixed bug in `group()` value traversal of the second `by()` where a
`CollectingBarrierStep` could produce an unexpected filtering effect when
`ReducingBarrierStep` or `SupplyingBarrierStep` instances were not taken into
account.
* Changed `DetachedFactory` to special case the handling of
`ComputerAdjacentVertex` which doesn't carry properties but still needs to be
detachable for OLAP cases.
* Deprecated `ProfilingAware.prepareForProfiling` method preferring to simply
`resetBarrierFromValueTraversal` from the `Grouping` interface after strategy
application.
diff --git a/docs/src/upgrade/release-3.8.x.asciidoc
b/docs/src/upgrade/release-3.8.x.asciidoc
index 9e51e4ac16..d404c2b915 100644
--- a/docs/src/upgrade/release-3.8.x.asciidoc
+++ b/docs/src/upgrade/release-3.8.x.asciidoc
@@ -150,6 +150,14 @@ version, the `none()` step was used to "throw away" all
traversers that passed i
renamed to `discard()`. The `discard()` step with its verb tone arguably makes
for a better name for that feature, but
it also helped make room for `none()` to be repurposed as `none(P)` which is a
complement to `any(P)` and `all(P) steps.
+==== Prevented using cap() inside repeat()
+
+`cap()` inside `repeat()` is now disallowed by the
`StandardVerificationStrategy`. Using `cap()` inside `repeat()` would
+have led to unexpected results since `cap()` isn't "repeat-aware". Because
`cap()` is a `SupplyingBarrier` that reduces
+the number of traversers to one, its use inside `repeat()` is limited.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-3195[TINKERPOP-3195]
+
==== Simplified Comparability Semantics
The previous system of ternary boolean semantics has been replaced with
simplified binary semantics. The triggers for
diff --git
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
index 99e015d957..2c698c7063 100644
---
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
+++
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
@@ -29,6 +29,7 @@ import
org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSid
import
org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectCapStep;
import
org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep;
import
org.apache.tinkerpop.gremlin.process.traversal.step.util.RequirementsStep;
+import
org.apache.tinkerpop.gremlin.process.traversal.step.util.SupplyingBarrierStep;
import
org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -61,8 +62,10 @@ public final class StandardVerificationStrategy extends
AbstractTraversalStrateg
if (Graph.Hidden.isHidden(label))
step.removeLabel(label);
}
- if (step instanceof ReducingBarrierStep &&
step.getTraversal().getParent() instanceof RepeatStep &&
step.getTraversal().getParent().getGlobalChildren().get(0).getSteps().contains(step))
- throw new VerificationException("The parent of a reducing
barrier can not be repeat()-step: " + step, traversal);
+ if ((step instanceof ReducingBarrierStep || step instanceof
SupplyingBarrierStep) &&
+ step.getTraversal().getParent() instanceof RepeatStep &&
+
step.getTraversal().getParent().getGlobalChildren().get(0).getSteps().contains(step))
+ throw new VerificationException("The parent of a
reducing/supplying barrier can not be repeat()-step: " + step, traversal);
// prevents silly stuff like g.V().emit()
if (step instanceof RepeatStep && null == ((RepeatStep)
step).getRepeatTraversal())
diff --git
a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
index 6bc20e4e21..a794cca224 100644
---
a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
+++
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
@@ -33,6 +33,7 @@ import org.junit.runners.Parameterized;
import java.util.Arrays;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.cap;
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.out;
import static
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.repeat;
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.sum;
@@ -58,6 +59,7 @@ public class StandardVerificationStrategyTest {
{repeat(out().fold().unfold()).times(2), false},
{repeat(sum()).times(2), false},
{repeat(out().count()), false},
+ {repeat(cap("x")), false},
{__.V().profile(), true},
{__.V().profile("metrics").cap("metrics"), true}
});