Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Template test for demonstrating issues with DataNucleus using the JDO API
branch: mongodb/empty-…

This branch is 1 commit ahead, 7 commits behind datanucleus:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


Empty query result list iterator bug

Testcase demonstrating a bug with empty query result iterator on MongoDB datastore.

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 problem will not show up if DataNucleus is forced to evaluate the list prior to invoking the iterator, for example by:

  • calling list size() method
  • calling one of makeTransient(), makePersistent(), etc PM methods

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. However, if one of the above methods is invoked, LazyLoadQueryResult class ends up calling getNextObject() method, removing empty result candidate cursors.

Something went wrong with that request. Please try again.