TisonKun 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_r351066450
 
 

 ##########
 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:
   I give this snippet a think. Here comes some thoughts I'd like to sync our 
opinion.
   
   1. We don't introduce extra complexity here. Previously we should make sure 
closing `ClusterClient` properly and right now we close the `JobClient`. It is 
about lifecycle management that we cannot avoid it conceptually.
   
   2. For code side, we can ease boilerplate code eventually as
   
   ```java
   .thenCompose((jobClient -> {
       try (jobClient) {
           return jobClient.getJobExecutionResult(classLoader);
       }
   }));
   ```
   
   here we need two changes: (1) Java 9 support resource reference in 
try-with-resource. Although we cannot bump codebase to Java 11 dropping Java 8 
for now, it is a predictable improvement once we move there. (2) 
`JobClient#close` can be tagged without `throw Exception` and so does 
`ClusterClient#close`. Their implementations don't throw checked exceptions and 
we cannot do too much when closing client failed. In this context, we just fail 
the completable future with the exception as expected.

----------------------------------------------------------------
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