Skip to content

Commit

Permalink
clean os even when statusFuture complete exceptionally (apache#12767)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlu90 authored Nov 12, 2021
1 parent c90c89b commit c1a3519
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;
Expand Down Expand Up @@ -888,14 +889,14 @@ public void onThrowable(Throwable t) {
}).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
Expand Down

0 comments on commit c1a3519

Please sign in to comment.