aljoscha commented on a change in pull request #10408: [FLINK-14992][client] Add job listener to execution environments URL: https://github.com/apache/flink/pull/10408#discussion_r354200182
########## File path: flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java ########## @@ -865,9 +900,20 @@ public JobExecutionResult execute(String jobName) throws Exception { "Cannot find compatible factory for specified execution.target (=%s)", configuration.get(DeploymentOptions.TARGET)); - return executorFactory + CompletableFuture<JobClient> jobClientFuture = executorFactory .getExecutor(configuration) .execute(plan, configuration); + + jobClientFuture.whenCompleteAsync((jobClient, throwable) -> { Review comment: I think we should return the result of `whenCompleteAsync`, this way, the returned future only returns when the job listener was invoked and has returned. This ensures that the job listener can still create a job client if necessary. Otherwise we have a race condition if the consumer of the returned future immediately closes the client. I think. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services