akalash commented on code in PR #21923: URL: https://github.com/apache/flink/pull/21923#discussion_r1114428581
########## flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java: ########## @@ -256,19 +259,27 @@ private final StreamTaskAsyncExceptionHandler asyncExceptionHandler; /** - * Flag to mark the task "in operation", in which case check needs to be initialized to true, so - * that early cancel() before invoke() behaves correctly. + * INITIALIZED: task constructor was called or on init state. RUNNING: task is in operation. + * FAILING: task is failing e.g., if an exception has occurred inside {@link #invoke()}. + * CANCELED: when this task is canceled. FINISHED: task successfully terminated. */ - private volatile boolean isRunning; + private enum TaskState { + FINISHED(Arrays.asList(new TaskState[] {})), + CANCELED(Arrays.asList(new TaskState[] {})), + RUNNING(Arrays.asList(new TaskState[] {CANCELED, FINISHED})), + INITIALIZED(Arrays.asList(new TaskState[] {RUNNING, CANCELED, FINISHED})); - /** Flag to mark this task as canceled. */ - private volatile boolean canceled; + private List<TaskState> validFromStates; + private boolean failing = false; Review Comment: +1. It's better to avoid mutable fields in enums -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org