eemario commented on code in PR #1448:
URL: https://github.com/apache/flink-agents/pull/1448#discussion_r4690111183
##########
runtime/src/test/java/org/apache/flink/agents/runtime/async/AsyncBatchExecutorTest.java:
##########
@@ -97,15 +99,23 @@ void
closeCancelsSubmissionsAndWaitsForManagedThreadCleanup() throws Exception {
executor.submit(
() -> {
started.countDown();
- new CountDownLatch(1).await();
- return "first";
+ try {
+ new CountDownLatch(1).await();
+ return "first";
+ } catch (InterruptedException e) {
+ runningInterrupted.countDown();
+ throw e;
+ }
});
- CompletableFuture<String> queued = executor.submit(() -> "queued");
+ CompletableFuture<Integer> queued =
executor.submit(queuedCalls::incrementAndGet);
assertThat(started.await(5, TimeUnit.SECONDS)).isTrue();
Future<?> closing = drivers.submit(executor::close);
assertThat(cleanupStarted.await(5, TimeUnit.SECONDS)).isTrue();
- assertThat(running.isCancelled()).isTrue();
+ assertThat(runningInterrupted.getCount()).isZero();
+ // shutdownNow may interrupt the callable before its result is
explicitly cancelled.
+ assertThat(running.isCompletedExceptionally()).isTrue();
assertThat(queued.isCancelled()).isTrue();
Review Comment:
Would it make sense to move the `queued.isCancelled()` and `queuedCalls`
assertions just after `closing.get(...)`? I checked this locally by adding a
latch immediately after `shutdownNow()` to pause the thread running `close()`.
Once the worker signalled `cleanupStarted`, `queued.isCancelled()` was still
`false`. After I released the latch and `close()` returned, it was `true`.
Checking those two assertions after `closing.get(...)` would avoid depending
on which thread gets scheduled first. The `closing.isDone()` check can stay
before `releaseCleanup.countDown()` to verify that `close()` waits for cleanup.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]