Fixes for RestIterator #473

Merged
giambattista.bloisi merged 3 commits from fix_pagination into main 2024-09-05 16:59:16 +02:00
1 changed files with 17 additions and 13 deletions
Showing only changes of commit 37b9bdc10c - Show all commits

View File

@ -176,19 +176,6 @@ public class RestIterator implements Iterator<String> {
*/
@Override
public boolean hasNext() {
if (this.recordQueue.isEmpty() && this.query.isEmpty()) {
disconnect();
return false;
}
return true;
}
/*
* (non-Javadoc)
* @see java.util.Iterator#next()
*/
@Override
public String next() {
synchronized (this.recordQueue) {
while (this.recordQueue.isEmpty() && !this.query.isEmpty()) {
try {
@ -198,6 +185,23 @@ public class RestIterator implements Iterator<String> {
throw new RuntimeException(e);
}
}
if (!this.recordQueue.isEmpty()) {
return true;
}
disconnect();
return false;
}
}
/*
* (non-Javadoc)
* @see java.util.Iterator#next()
*/
@Override
public String next() {
synchronized (this.recordQueue) {
return this.recordQueue.poll();
}
}