Skip to content

Commit

Permalink
Empty result iterator's hasNext() returning true
Browse files Browse the repository at this point in the history
Calling hasNext() method on an empty lazy-loaded query result iterator
returns true while next() method returns null. Consequently, iterating
over such a list results in a single null element being processed.

The reason for this strange behavior is QueryResultIterator's hasNext()
relying on the existence of at least one candidate result, failing to
check if candidate's cursor contains at least one object.

This quick fix ensures that only candidates with a non-empty cursor are
added to query result candidate list.
  • Loading branch information
marcin1j committed Dec 31, 2013
1 parent c46c29b commit 050cca8
Showing 1 changed file with 4 additions and 1 deletion.
Expand Up @@ -113,7 +113,10 @@ public CandidateClassResult(AbstractClassMetaData cmd, DBCursor curs, int[] fpMe


public void addCandidateResult(AbstractClassMetaData cmd, DBCursor cursor, int[] fpMembers) public void addCandidateResult(AbstractClassMetaData cmd, DBCursor cursor, int[] fpMembers)
{ {
candidateResults.add(new CandidateClassResult(cmd, cursor, fpMembers)); if (cursor.hasNext())
{
candidateResults.add(new CandidateClassResult(cmd, cursor, fpMembers));
}
} }


/** /**
Expand Down

0 comments on commit 050cca8

Please sign in to comment.