Skip to content

Commit

Permalink
OGM-1111 Iterators will throw NoSuchElementException
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideD authored and gsmet committed Dec 16, 2016
1 parent c9e991f commit 38ba328
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Expand Up @@ -11,6 +11,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;

import org.hibernate.LockMode;
import org.hibernate.dialect.lock.LockingStrategy;
Expand Down Expand Up @@ -218,7 +219,8 @@ public Tuple next() {
next = next( iterator );
return current;
}
return null;

throw new NoSuchElementException();
}

@Override
Expand Down
Expand Up @@ -7,6 +7,7 @@
package org.hibernate.ogm.datastore.ehcache.persistencestrategy.kind.impl;

import java.util.Iterator;
import java.util.NoSuchElementException;

import org.hibernate.ogm.datastore.ehcache.impl.Cache;
import org.hibernate.ogm.datastore.ehcache.persistencestrategy.common.impl.CacheNames;
Expand Down Expand Up @@ -128,9 +129,13 @@ public boolean hasNext() {

@Override
public Tuple next() {
Tuple current = createTuple( entityCache.get( this.next ) );
this.next = next( this.iterator );
return current;
if ( hasNext ) {
Tuple current = createTuple( entityCache.get( this.next ) );
this.next = next( this.iterator );
return current;
}

throw new NoSuchElementException();
}

@Override
Expand Down

0 comments on commit 38ba328

Please sign in to comment.