Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ce5a004

Browse files
committedMar 17, 2020
DATAES-764 - StreamQueries#streamResults does not clear scroll context when finished
1 parent 300eb31 commit ce5a004

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎src/main/java/org/springframework/data/elasticsearch/core/StreamQueries.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* Utility to support streaming queries.
2727
*
2828
* @author Mark Paluch
29+
* @author Sascha Woo
2930
* @since 3.2
3031
*/
3132
abstract class StreamQueries {
@@ -56,8 +57,7 @@ static <T> CloseableIterator<T> streamResults(ScrolledPage<T> page,
5657
@Override
5758
public void close() {
5859
try {
59-
// Clear scroll on cluster only in case of error (cause elasticsearch auto clear scroll when it's done)
60-
if (!finished && scrollId != null && currentHits != null && currentHits.hasNext()) {
60+
if (scrollId != null) {
6161
clearScroll.accept(scrollId);
6262
}
6363
} finally {
@@ -73,7 +73,7 @@ public boolean hasNext() {
7373
return false;
7474
}
7575
// Test if it remains hits
76-
if (currentHits == null || !currentHits.hasNext()) {
76+
if (!currentHits.hasNext()) {
7777
// Do a new request
7878
ScrolledPage<T> scroll = continueFunction.apply(scrollId);
7979
// Save hits and scroll id

0 commit comments

Comments
 (0)
Please sign in to comment.