tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [11/50] incubator-tinkerpop git commit: Improve validations in ServerStrategy.
Date Wed, 16 Mar 2016 14:39:53 GMT
Improve validations in ServerStrategy.


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

Branch: refs/heads/TINKERPOP-575
Commit: 659b52adeaa682b9d944b816683a857599701083
Parents: 523d2bb
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Thu Mar 10 17:11:57 2016 -0500
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Wed Mar 16 09:49:10 2016 -0400

----------------------------------------------------------------------
 .../server/traversal/strategy/ServerStrategy.java      | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/659b52ad/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/server/traversal/strategy/ServerStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/server/traversal/strategy/ServerStrategy.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/server/traversal/strategy/ServerStrategy.java
index 4a3b045..f353bae 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/server/traversal/strategy/ServerStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/server/traversal/strategy/ServerStrategy.java
@@ -61,12 +61,19 @@ public class ServerStrategy extends AbstractTraversalStrategy<TraversalStrategy.
         if (!(traversal.getParent() instanceof EmptyStep))
             return;
 
-        if (traversal.getGraph().isPresent() && !(traversal.getGraph().get() instanceof
ServerGraph))
-            throw new IllegalStateException("Graph attached to Traversal is not a ServerGraph
instance");
+        if (!traversal.getGraph().isPresent())
+            throw new IllegalStateException("ServerStrategy expects a ServerGraph instance
attached to the Traversal");
+
+        if (!(traversal.getGraph().get() instanceof ServerGraph))
+            throw new IllegalStateException("ServerStrategy expects a ServerGraph instance
attached to the Traversal");
+
+        final ServerGraph serverGraph = (ServerGraph) traversal.getGraph().get();
+        if (null == serverGraph.getConnection())
+            throw new IllegalStateException("ServerStrategy expects ServerGraph instance
to have a ServerConnection");
 
         final Traversal.Admin<?, ?> serverTraversal = new DefaultTraversal<>();
         TraversalHelper.removeToTraversal(traversal.getStartStep(), EmptyStep.instance(),
(Traversal.Admin) serverTraversal);
-        final ServerResultStep serverStep = new ServerResultStep(traversal, serverTraversal,
((ServerGraph) traversal.getGraph().get()).getConnection());
+        final ServerResultStep serverStep = new ServerResultStep(traversal, serverTraversal,
serverGraph.getConnection());
         traversal.addStep(serverStep);
 
         assert traversal.getStartStep().equals(serverStep);


Mime
View raw message