leekeiabstraction commented on code in PR #2303:
URL: https://github.com/apache/fluss/pull/2303#discussion_r2659861260


##########
fluss-server/src/test/java/org/apache/fluss/server/replica/ReplicaTest.java:
##########
@@ -716,8 +723,13 @@ void testRestore(@TempDir Path snapshotKvTabletDirPath) 
throws Exception {
         // test recover with schema evolution.
         short newSchemaId = 2;
         // trigger one snapshot.
-        scheduledExecutorService.removeNonPeriodicScheduledTask();
-        scheduledExecutorService.triggerNonPeriodicScheduledTask();
+        try {
+            scheduledExecutorService.removeNonPeriodicScheduledTask();
+        } catch (java.util.NoSuchElementException ignored) {

Review Comment:
   Similarly here



##########
fluss-server/src/test/java/org/apache/fluss/server/replica/ReplicaTest.java:
##########
@@ -690,10 +690,17 @@ void testRestore(@TempDir Path snapshotKvTabletDirPath) 
throws Exception {
 
         // We have to remove the first scheduled snapshot task since it's for 
the previous kv tablet
         // whose rocksdb has been dropped.
-        scheduledExecutorService.removeNonPeriodicScheduledTask();
 
-        // trigger one snapshot,
-        scheduledExecutorService.triggerNonPeriodicScheduledTask();
+        // Remove the stale snapshot task if it exists
+        try {
+            scheduledExecutorService.removeNonPeriodicScheduledTask();
+        } catch (java.util.NoSuchElementException ignored) {
+            // no-op: no scheduled task to remove
+        }

Review Comment:
   Instead of handling exception from calling sites, I suggest handling 
exception (or even better, address what causes it by not removing from empty 
queue.) This is so that we do not have boilerplates at calling sites.



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