merlimat commented on code in PR #4927:
URL: https://github.com/apache/bookkeeper/pull/4927#discussion_r4449598767


##########
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:
   Moved the client into try-with-resources, so it is closed when the assertion 
fails too (44253d0d99).
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_



-- 
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]

Reply via email to