Copilot commented on code in PR #4927:
URL: https://github.com/apache/bookkeeper/pull/4927#discussion_r4449567948
##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestSpeculativeRead.java:
##########
@@ -319,6 +320,26 @@ public void testSpeculativeReadScheduledTaskCancel()
throws Exception {
}
}
+ /**
+ * Test that a read of several entries cancels the speculative read tasks
+ * of all of them when it completes.
+ */
+ @Test
+ public void testSpeculativeReadTasksCancelledOnCompletion() throws
Exception {
+ long id = getLedgerToRead(3, 2);
+ // longer than the wait for the scheduler to terminate below
+ BookKeeperTestClient bkspec = createClient(60000);
+ LedgerHandle l = bkspec.openLedger(id, digestType, passwd);
+ l.read(0, 9).close();
+
+ // the scheduler still runs the delayed tasks that weren't cancelled
before its shutdown
+ OrderedScheduler scheduler = bkspec.getClientCtx().getScheduler();
+ scheduler.shutdown();
+ assertTrue("Speculative read tasks of the completed read are still
scheduled",
+ scheduler.awaitTermination(10, TimeUnit.SECONDS));
+ bkspec.close();
Review Comment:
If the termination assertion fails, or the read/await is interrupted, this
close is skipped and the extra client's worker threads, timer, network
connections, and metadata client remain open. The fixture teardown only closes
`bkc`, not this locally created client. Use try-with-resources so the
regression test also releases its client on failure.
--
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]