You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2022/10/25 01:58:49 UTC

[GitHub] [james-project] chibenwa commented on a diff in pull request #1272: JAMES-3825 Cancel tasks upon graceful shutdown - waiting to the cancelled listener is completed

chibenwa commented on code in PR #1272:
URL: https://github.com/apache/james-project/pull/1272#discussion_r1003923119


##########
server/task/task-memory/src/main/java/org/apache/james/task/SerialTaskManagerWorker.java:
##########
@@ -173,7 +176,16 @@ public Publisher<Void> fail(TaskId taskId, Publisher<Optional<TaskExecutionDetai
     @Override
     public void close() {
         Optional.ofNullable(runningTask.get())
-            .ifPresent(task -> cancelTask(task.getT1()));
+            .ifPresent(task -> {
+                cancelTask(task.getT1());
+                while (cancelledTasks.contains(task.getT1())) {
+                    try {
+                        TimeUnit.MILLISECONDS.sleep(500);
+                    } catch (InterruptedException e) {
+                        throw new RuntimeException(e);
+                    }
+                }

Review Comment:
   Please use awaitility for the dirty job here...



-- 
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: notifications-unsubscribe@james.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org