aljoscha commented on a change in pull request #10313: [FLINK-14840] Use 
Executor interface in SQL cli
URL: https://github.com/apache/flink/pull/10313#discussion_r350721049
 
 

 ##########
 File path: 
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/local/result/CollectStreamResult.java
 ##########
 @@ -138,7 +146,10 @@ protected boolean isRetrieving() {
                @Override
                public void run() {
                        try {
-                               deployer.run();
+                               // fetch the job execution result, so that an 
attached cluster will shut down
+                               deployer
+                                               .run()
+                                               .thenCompose((jobClient -> 
jobClient.getJobExecutionResult(classLoader)));
 
 Review comment:
   You're right. I noticed that working with a `JobClient` that needs to be 
closed is very cumbersome. The code becomes:
   ```
   deployer
                .deploy()
                .thenCompose((jobClient -> {
                        CompletableFuture<JobExecutionResult> result =
                                        
jobClient.getJobExecutionResult(classLoader);
                        try {
                                jobClient.close();
                        } catch (Exception e) {
                                throw new CompletionException("Error while 
closing JobClient.", e);
                        }
                        return result;
                }));
   ```
   It would be easier to write correct code if the `JobClient` didn't need 
closing.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to