You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2021/11/12 05:36:56 UTC

[pulsar] branch master updated: clean os even when statusFuture complete exceptionally (#12767)

This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new c1a3519  clean os even when statusFuture complete exceptionally (#12767)
c1a3519 is described below

commit c1a3519df4710aa2ecd41c7e8d8fd55f3c37296b
Author: Neng Lu <nl...@streamnative.io>
AuthorDate: Thu Nov 11 21:36:02 2021 -0800

    clean os even when statusFuture complete exceptionally (#12767)
---
 .../org/apache/pulsar/client/admin/internal/FunctionsImpl.java   | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/FunctionsImpl.java b/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/FunctionsImpl.java
index a53da9d..1e1f66f 100644
--- a/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/FunctionsImpl.java
+++ b/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/FunctionsImpl.java
@@ -25,6 +25,7 @@ import com.google.gson.Gson;
 import io.netty.handler.codec.http.HttpHeaders;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.nio.channels.FileChannel;
 import java.util.List;
 import java.util.Set;
@@ -888,14 +889,14 @@ public class FunctionsImpl extends ComponentResource implements Functions {
                         }).toCompletableFuture();
 
             statusFuture
-                    .thenAccept(status -> {
+                    .whenComplete((status, throwable) -> {
                         try {
                             os.close();
-                        } catch (Exception e) {
+                        } catch (IOException e) {
                             future.completeExceptionally(getApiException(e));
-                            return;
                         }
-
+                    })
+                    .thenAccept(status -> {
                         if (status.getStatusCode() < 200 || status.getStatusCode() >= 300) {
                             future.completeExceptionally(
                                     getApiException(Response