ISPN-4626 Avoid locking on hasNext unless necessary