You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/12/07 20:02:40 UTC

[17/50] tinkerpop git commit: Added a short sleep to prevent traversal from finishing before it can be interrupted.

Added a short sleep to prevent traversal from finishing before it can be interrupted.


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

Branch: refs/heads/TINKERPOP-1490
Commit: 9983fd210872d57750d49191c391ba8e380e6023
Parents: 7bb77c6
Author: Ted Wilmes <tw...@gmail.com>
Authored: Tue Nov 22 10:53:03 2016 -0600
Committer: Ted Wilmes <tw...@gmail.com>
Committed: Tue Nov 22 10:53:03 2016 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                   |  1 +
 .../traversal/TraversalInterruptionComputerTest.java | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9983fd21/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 584f9e3..793e953 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -59,6 +59,7 @@ TinkerPop 3.2.4 (Release Date: NOT OFFICIALLY RELEASED YET)
 * 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.
 * The root traversal now throws regular `NoSuchElementException` instead of `FastNoSuchElementException`. (*breaking*)
+* Added a short sleep to prevent traversal from finishing before it can be interrupted during `TraversalInterruptionComputerTest`.
 
 [[release-3-2-3]]
 TinkerPop 3.2.3 (Release Date: October 17, 2016)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9983fd21/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalInterruptionComputerTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalInterruptionComputerTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalInterruptionComputerTest.java
index c3a1042..d3994f1 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalInterruptionComputerTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalInterruptionComputerTest.java
@@ -75,6 +75,17 @@ public class TraversalInterruptionComputerTest extends AbstractGremlinProcessTes
             try {
                 final Traversal traversal = traversalMaker.apply(g).sideEffect(traverser -> {
                     startedIterating.countDown();
+                    try {
+                        // artificially slow down the traversal execution so that
+                        // this test has a chance to interrupt it before it finishes
+                        Thread.sleep(100);
+                    } catch (InterruptedException e) {
+                        // if the traversal is interrupted while in this
+                        // sleep, reassert the interrupt so that the thread is
+                        // re-marked as interrupted and correctly handled as
+                        // an interrupted traversal
+                        Thread.currentThread().interrupt();
+                    }
                 });
                 traversal.iterate();
             } catch (Exception ex) {
@@ -84,9 +95,9 @@ public class TraversalInterruptionComputerTest extends AbstractGremlinProcessTes
 
         t.start();
 
-        // total time for test should not exceed 5 seconds - this prevents the test from just hanging and allows
+        // total time for test should not exceed 1 second - this prevents the test from just hanging and allows
         // it to finish with failure
-        assertThat(startedIterating.await(5000, TimeUnit.MILLISECONDS), CoreMatchers.is(true));
+        assertThat(startedIterating.await(1000, TimeUnit.MILLISECONDS), CoreMatchers.is(true));
 
         t.interrupt();
         t.join();