You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/10/12 05:49:02 UTC

[GitHub] [incubator-seatunnel] hailin0 commented on a diff in pull request #3053: [Improve] close resources in finally block

hailin0 commented on code in PR #3053:
URL: https://github.com/apache/incubator-seatunnel/pull/3053#discussion_r993021088


##########
seatunnel-core/seatunnel-core-flink/src/main/java/org/apache/seatunnel/core/flink/command/FlinkApiTaskExecuteCommand.java:
##########
@@ -80,9 +80,10 @@ public void execute() throws CommandExecuteException {
                 FlinkEnvironment> execution = new ExecutionFactory<>(executionContext).createExecution()) {
             prepare(executionContext.getEnvironment(), sources, transforms, sinks);
             execution.start(sources, transforms, sinks);
-            close(sources, transforms, sinks);
         } catch (Exception e) {
             throw new CommandExecuteException("Execute Flink task error", e);
+        } finally {
+            close(sources, transforms, sinks);

Review Comment:
   example
   
   ```java
           List<BaseSource<FlinkEnvironment>> sources = executionContext.getSources();
           List<BaseTransform<FlinkEnvironment>> transforms = executionContext.getTransforms();
           List<BaseSink<FlinkEnvironment>> sinks = executionContext.getSinks();
           try {
               ...
           } catch() {
               ...
           } finally {
                close(sources, transforms, sinks);
           }
   ```



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org