-
Notifications
You must be signed in to change notification settings - Fork 135
Closed
Labels
api: spannerIssues related to the googleapis/java-spanner API.Issues related to the googleapis/java-spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
The following test case shows that the callback will continue to be called after the callback has returned PAUSE and the result set has been cancelled. This will only happen if the callback method does not call resultSet.tryNext().
@Test
public void testCallbackIsNotCalledWhilePausedAndCanceled() throws InterruptedException, ExecutionException {
Executor executor = Executors.newSingleThreadExecutor();
ResultSet delegate = mock(ResultSet.class);
final AtomicInteger callbackCounter = new AtomicInteger();
try (AsyncResultSetImpl rs =
new AsyncResultSetImpl(simpleProvider, delegate, AsyncResultSetImpl.DEFAULT_BUFFER_SIZE)) {
rs.setCallback(executor,
resultSet -> {
callbackCounter.getAndIncrement();
return CallbackResponse.PAUSE;
});
rs.cancel();
while (callbackCounter.get() < 100) {
Thread.yield();
}
assertThat(callbackCounter.get()).isGreaterThan(99);
}
}Metadata
Metadata
Assignees
Labels
api: spannerIssues related to the googleapis/java-spanner API.Issues related to the googleapis/java-spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.