neo4j/neo4j — pull request #1011 by tinwelint (2013-07-28 23:30:31+00:00)
Title: Fixes an ArrayIndexOutOfBounds issue iterating over relationships

Issue manifests in calling #next() on the iterator gotten from
Node#getRelationships(...) would suddenly throw ArrayIndexOutOfBoundsException.

Cause of the issue was this: Internally a RelationshipIterator would have
all internal per-type relationship iterators in an array. Exhausting one
would try to move to the next, if any. The check that tested if there were
more per-type iterators to visit incremented the array index and if that
check would yield false an additional check to load more relationships
would be made, and if that also yielded false the current per-type iterator
would be tested again. In this case another transaction would have created
another relationship so that relationship would be returned.
The consecutive call to #next() would start off getting the current
per-type iterator and this is where the array index would point to an
index that was one too high than allowed.

Fix is to not increment the index in the check, but instead increment if
the check yields true.