cadonna commented on code in PR #15870: URL: https://github.com/apache/kafka/pull/15870#discussion_r1591277510
########## streams/src/main/java/org/apache/kafka/streams/processor/internals/TaskManager.java: ########## @@ -602,6 +608,47 @@ private void removeUnusedTaskFromStateUpdater(final TaskId taskId) { tasks.addPendingTaskToCloseClean(taskId); } + private void addToTasksToClose(final Map<TaskId, CompletableFuture<StateUpdater.RemovedTaskResult>> futures, + final Set<Task> tasksToCloseCleanFromStateUpdater, + final Set<Task> tasksToCloseDirtyFromStateUpdater) { + iterateAndActOnFuture(futures, removedTaskResult -> { + final Task task = removedTaskResult.task(); + final Optional<RuntimeException> exception = removedTaskResult.exception(); + if (exception.isPresent()) { + tasksToCloseDirtyFromStateUpdater.add(task); + } else { + tasksToCloseCleanFromStateUpdater.add(task); + } + }); + } + + private void iterateAndActOnFuture(final Map<TaskId, CompletableFuture<StateUpdater.RemovedTaskResult>> futures, + final java.util.function.Consumer<StateUpdater.RemovedTaskResult> action) { + for (final Map.Entry<TaskId, CompletableFuture<StateUpdater.RemovedTaskResult>> entry : futures.entrySet()) { + final TaskId taskId = entry.getKey(); + final CompletableFuture<StateUpdater.RemovedTaskResult> future = entry.getValue(); + try { + final StateUpdater.RemovedTaskResult removedTaskResult = waitForFuture(taskId, future); + action.accept(removedTaskResult); + } catch (final ExecutionException executionException) { + log.warn("An exception happened when removing task {} from the state updater. The exception will be handled later: ", + taskId, executionException); + } catch (final InterruptedException ignored) { } Review Comment: I am actually in favor of treating them as fatal and throw an `IllegalStateException` to make it more explicit that interruption of a stream thread should not happen. WDYT? -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org