added the try/catch model to nextTraverser() as well. Tweaked the docs and CHANGELOG a bit.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3b57bd44 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3b57bd44 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3b57bd44 Branch: refs/heads/master Commit: 3b57bd440047cf66f12f2cc82ba876c7fc378c47 Parents: 0f84e43 fe7c422 Author: Marko A. Rodriguez <okramma...@gmail.com> Authored: Wed Nov 2 11:12:43 2016 -0600 Committer: Marko A. Rodriguez <okramma...@gmail.com> Committed: Wed Nov 2 11:12:43 2016 -0600 ---------------------------------------------------------------------- CHANGELOG.asciidoc | 1 + .../upgrade/release-3.2.x-incubating.asciidoc | 9 +++++ .../traversal/util/DefaultTraversal.java | 35 ++++++++++++-------- .../process/traversal/CoreTraversalTest.java | 35 ++++++++++++++++++++ .../PartitionStrategyProcessTest.java | 3 +- 5 files changed, 68 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3b57bd44/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --cc CHANGELOG.asciidoc index faec861,246244e..fbab643 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@@ -37,6 -33,7 +37,7 @@@ TinkerPop 3.2.4 (Release Date: NOT OFFI * Added `Pick.none` and `Pick.any` to the serializers and importers. * Added a class loader to `TraversalStrategies.GlobalCache` which guarantees strategies are registered prior to `GlobalCache.getStrategies()`. * Fixed a severe bug where `GraphComputer` strategies are not being loaded until the second use of the traversal source. -* Traversals now throw regular NoSuchElementException instead of FastNoSuchElementException. ++* The root traversal now throws regular `NoSuchElementException` instead of `FastNoSuchElementException`. (*breaking*) [[release-3-2-3]] TinkerPop 3.2.3 (Release Date: October 17, 2016) http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3b57bd44/docs/src/upgrade/release-3.2.x-incubating.asciidoc ---------------------------------------------------------------------- diff --cc docs/src/upgrade/release-3.2.x-incubating.asciidoc index 142e349,1602600..8574b88 --- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc +++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc @@@ -32,20 -32,15 +32,29 @@@ Please see the link:https://github.com/ Upgrading for Users ~~~~~~~~~~~~~~~~~~~ +If/Then-Semantics with Choose Step +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Gremlin's `choose()`-step supports if/then/else-semantics. Thus, to effect if/then-semantics, `identity()` was required. +Thus, the following two traversals below are equivalent with the later being possible in this release. + +[source,groovy] +---- +g.V().choose(hasLabel('person'),out('created'),identity()) +g.V().choose(hasLabel('person'),out('created')) +---- + +See: link:https://issues.apache.org/jira/browse/TINKERPOP-1508[TINKERPOP-1508] + + FastNoSuchElementException converted to regular NoSuchElementException + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + -In gremlin 3.2.x a call to Traversal#next() that did not have a result would throw a FastNoSuchElementException. -This has been changed to a regular NoSuchElementException that includes the stack trace. Code that explicitly catches -FastNoSuchElementException should be converted to NoSuchElementException. ++Previously, a call to `Traversal.next()` that did not have a result would throw a `FastNoSuchElementException`. ++This has been changed to a regular `NoSuchElementException` that includes the stack trace. Code that explicitly catches ++`FastNoSuchElementException` should be converted to check for the more general class of `NoSuchElementException`. + + See: link:https://issues.apache.org/jira/browse/TINKERPOP-1330[TINKERPOP-1330] + Upgrading for Providers ~~~~~~~~~~~~~~~~~~~~~~~ http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3b57bd44/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java ---------------------------------------------------------------------- diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java index 5bd01da,a1d21fb..3c21e37 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java @@@ -158,18 -159,18 +159,22 @@@ public class DefaultTraversal<S, E> imp @Override public List<Step> getSteps() { -- return unmodifiableSteps; ++ return this.unmodifiableSteps; } @Override public Traverser.Admin<E> nextTraverser() { -- if (!this.locked) this.applyStrategies(); -- if (this.lastTraverser.bulk() > 0L) { -- final Traverser.Admin<E> temp = this.lastTraverser; -- this.lastTraverser = EmptyTraverser.instance(); -- return temp; -- } else { -- return this.finalEndStep.next(); ++ try { ++ if (!this.locked) this.applyStrategies(); ++ if (this.lastTraverser.bulk() > 0L) { ++ final Traverser.Admin<E> temp = this.lastTraverser; ++ this.lastTraverser = EmptyTraverser.instance(); ++ return temp; ++ } else { ++ return this.finalEndStep.next(); ++ } ++ } catch (final FastNoSuchElementException e) { ++ throw this.parent instanceof EmptyStep ? new NoSuchElementException() : e; } } @@@ -181,11 -182,21 +186,15 @@@ @Override public E next() { - if (!this.locked) this.applyStrategies(); - if (this.lastTraverser.bulk() == 0L) - this.lastTraverser = this.finalEndStep.next(); - this.lastTraverser.setBulk(this.lastTraverser.bulk() - 1L); - return this.lastTraverser.get(); + try { + if (!this.locked) this.applyStrategies(); + if (this.lastTraverser.bulk() == 0L) + this.lastTraverser = this.finalEndStep.next(); + this.lastTraverser.setBulk(this.lastTraverser.bulk() - 1L); + return this.lastTraverser.get(); - } - catch(FastNoSuchElementException e) { - if(parent == EmptyStep.instance()) { - throw new NoSuchElementException(); - } - else { - throw e; - } ++ } catch (final FastNoSuchElementException e) { ++ throw this.parent instanceof EmptyStep ? new NoSuchElementException() : e; + } } @Override