tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject incubator-tinkerpop git commit: Improve validations in ServerStrategy.
Date Thu, 10 Mar 2016 22:12:28 GMT
Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-575 3f13b34e4 -> b32d0c0d8


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/b32d0c0d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/b32d0c0d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/b32d0c0d

Branch: refs/heads/TINKERPOP-575
Commit: b32d0c0d83727d441b03345b113f7f6af78792c2
Parents: 3f13b34
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Thu Mar 10 17:11:57 2016 -0500
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Thu Mar 10 17:11:57 2016 -0500

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


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b32d0c0d/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