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/06/30 15:23:07 UTC
[4/5] tinkerpop git commit: Removed potential for NPEs when
validating IDs given to vertices()/edges()
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 <sp...@genoprime.com>
Authored: Thu Jun 30 05:48:01 2016 -0400
Committer: Stephen Mallette <sp...@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();
}
}