Skip to content

Commit

Permalink
test: fix potential race condition in Async ResultSet
Browse files Browse the repository at this point in the history
If an AsyncResultSet was paused directly after receiving its last row and
then cancelled while in paused mode, there was a small chance that the
callback would not be called a last time to indicate to the user that the
result set had been cancelled.

Updates #327
  • Loading branch information
olavloite committed Jul 9, 2020
1 parent fd2485a commit 161db8e
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -381,11 +381,11 @@ public Void call() throws Exception {
while (!stop) {
waitIfPaused();
startCallbackIfNecessary();
synchronized (monitor) {
stop = state.shouldStop || cursorReturnedDoneOrException;
}
// Make sure we wait until the callback runner has actually finished.
consumingLatch.await();
synchronized (monitor) {
stop = cursorReturnedDoneOrException;
}
}
} finally {
if (executorProvider.shouldAutoClose()) {
Expand Down

0 comments on commit 161db8e

Please sign in to comment.