ISPN-4626 Avoid locking on hasNext unless necessary
ISPN-4630 DistributedEntryRetriever throws NPE if iterator is closed
before processing all responses

* Fixed issue where null check was done on wrong objects