tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [4/5] tinkerpop git commit: Removed potential for NPEs when validating IDs given to vertices()/edges()
Date Thu, 30 Jun 2016 15:23:07 GMT
Removed potential for NPEs when validating IDs given to vertices()/edges()


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

Branch: refs/heads/tp31
Commit: 1e0c581c90b67a44121f8ec7258ea171e7c0bfe7
Parents: 099e6bc
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Thu Jun 30 05:48:01 2016 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Thu Jun 30 05:48:01 2016 -0400

----------------------------------------------------------------------
 .../gremlin/tinkergraph/structure/TinkerGraph.java       | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1e0c581c/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
index edffab9..af7245a 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
@@ -351,9 +351,14 @@ public final class TinkerGraph implements Graph {
     }
 
     private void validateHomogenousIds(final List<Object> ids) {
-        final Class firstClass = ids.get(0).getClass();
-        for (Object id : ids) {
-            if (!id.getClass().equals(firstClass))
+        final Iterator<Object> iterator = ids.iterator();
+        Object id = iterator.next();
+        if (id == null)
+            throw Graph.Exceptions.idArgsMustBeEitherIdOrElement();
+        final Class firstClass = id.getClass();
+        while (iterator.hasNext()) {
+            id = iterator.next();
+            if (id == null || !id.getClass().equals(firstClass))
                 throw Graph.Exceptions.idArgsMustBeEitherIdOrElement();
         }
     }


Mime
View raw message