wuchenxi123 commented on a change in pull request #11112:
URL: https://github.com/apache/pulsar/pull/11112#discussion_r664972759



##########
File path: 
pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstance.java
##########
@@ -158,9 +177,25 @@ private void processAsyncResults(BiConsumer<Record, 
JavaExecutionResult> resultC
     }
 
     @Override
-    public void close() {
+    public void close() throws Exception {
         context.close();
         executor.shutdown();
+        if (null != function && function instanceof HookFunction) {
+            try {
+                ((HookFunction) function).cleanup();
+            } catch (Exception e) {
+                log.error("function closeResource occurred exception", e);
+                throw e;
+            }
+        }
+        if (null != javaUtilFunction && javaUtilFunction instanceof 
HookFunction) {
+            try {
+                ((HookFunction) javaUtilFunction).cleanup();
+            } catch (Exception e) {

Review comment:
       I think HookFunction can provide users with additional choices, and it 
also makes the responsibilities of each method of Function more single and 
clear, please think again




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to