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/03/22 15:59:34 UTC

[GitHub] [incubator-seatunnel] Rianico commented on a change in pull request #1530: [Feature][core] Add close method in plugin.

Rianico commented on a change in pull request #1530:
URL: https://github.com/apache/incubator-seatunnel/pull/1530#discussion_r832362310



##########
File path: seatunnel-core/seatunnel-core-base/src/main/java/org/apache/seatunnel/command/BaseTaskExecuteCommand.java
##########
@@ -73,6 +72,30 @@ protected final void prepare(E env, List<? extends Plugin<E>>... plugins) {
         }
     }
 
+    /**
+     * Execute close method defined in {@link org.apache.seatunnel.plugin.Plugin}
+     *
+     * @param plugins plugin list
+     */
+    @SafeVarargs
+    protected final void close(List<? extends Plugin<E>>... plugins) {
+        Optional<RuntimeException> exceptionHolder = Optional.empty();
+        for (List<? extends Plugin<E>> pluginList : plugins) {
+            for (Plugin<E> plugin : pluginList) {
+                try (Plugin<?> closed = plugin) {
+                    // ignore
+                } catch (Exception e) {
+                    exceptionHolder = Optional.of(new RuntimeException(String.format(
+                            "plugin %s close error", plugin.getClass().getName()), exceptionHolder.orElse(null)));

Review comment:
       If mutiple plugins close failedly, the subsequent  exception will cover the previous exception and we will lose the previouse exception info.
   Maybe we can save all exception firstly (e.g. plugin -> exception) , continue executing next plugin's `close()` function, and throw the exception or return error message to notify the user which plugin close failedly.




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