tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [1/2] tinkerpop git commit: TINKERPOP-1675 Throw underlying unchecked exception in processNextStart
Date Thu, 25 May 2017 13:54:07 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/tp32 1ee5b3753 -> 8812f85a0


TINKERPOP-1675 Throw underlying unchecked exception in processNextStart

For consistency with previous behavior, if an unchecked exception is
set on the returned future throw that instead of the wrapped
CompletionException.


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

Branch: refs/heads/tp32
Commit: 6813e9efd86a4d032d3106000fb5e805deb26454
Parents: afa3432
Author: Andrew Tolbert <andrew.tolbert@datastax.com>
Authored: Mon May 22 12:14:15 2017 -0500
Committer: Andrew Tolbert <andrew.tolbert@datastax.com>
Committed: Mon May 22 12:20:27 2017 -0500

----------------------------------------------------------------------
 .../remote/traversal/step/map/RemoteStep.java    | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6813e9ef/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
index 3e19097..8f7d12b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
@@ -30,6 +30,7 @@ import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 
 import java.util.NoSuchElementException;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -57,7 +58,23 @@ public final class RemoteStep<S, E> extends AbstractStep<S, E>
{
 
     @Override
     protected Traverser.Admin<E> processNextStart() throws NoSuchElementException {
-        if (null == this.remoteTraversal) promise().join();
+        if (null == this.remoteTraversal) {
+            try {
+                promise().join();
+            } catch (CompletionException e) {
+                Throwable cause = e.getCause();
+                // If the underlying future failed, join() will throw a CompletionException,
for consistency
+                // with previous behavior:
+                // - Throw underlying exception if it was unchecked (RuntimeException or
Error).
+                // - Wrap in IllegalStateException otherwise.
+                if (cause instanceof RuntimeException) {
+                    throw (RuntimeException) cause;
+                } else if (cause instanceof Error) {
+                    throw (Error) cause;
+                }
+                throw new IllegalStateException(cause);
+            }
+        }
         return this.remoteTraversal.nextTraverser();
     }
 


Mime
View raw message