Skip to content

Commit 004ea2e

Browse files
committed
Query iterator remove throws UnsupportedOperation
Current implementaton is misleading, it remove from a temporary internal list, not from the collection. Simply not supporting the optional operation makes more sense. Also, current implementation has a major bug. NoSuchElementException on no hasNext should have been IllegalStateException when next as not been called piror, and remove should be on currentIndex - 1.
1 parent 9d0d98c commit 004ea2e

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/com/microsoft/azure/documentdb/QueryIterable.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,11 @@ public T next() {
117117
}
118118

119119
/**
120-
* Removes the current value.
120+
* Remove not supported.
121121
*/
122122
@Override
123123
public void remove() {
124-
if (!hasNext()) throw new NoSuchElementException();
125-
if (currentIndex < items.size()) {
126-
items.remove(currentIndex);
127-
}
124+
throw new UnsupportedOperationException("remove");
128125
}
129126

130127
};

0 commit comments

Comments
 (0)