Skip to content

Commit

Permalink
Fix: Exception being ignored in PulsarAdmin (apache#7510)
Browse files Browse the repository at this point in the history
Co-authored-by: Jerry Peng <[email protected]>
  • Loading branch information
jerrypeng and Jerry Peng authored Jul 11, 2020
1 parent 5fd96e2 commit 77ea9b8
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ public CompletableFuture<Void> createFunctionAsync(FunctionConfig functionConfig
} else {
future.complete(null);
}
})
.exceptionally(throwable -> {
future.completeExceptionally(getApiException(throwable));
return null;
});

} catch (Exception e) {
Expand Down Expand Up @@ -472,6 +476,10 @@ public CompletableFuture<Void> updateFunctionAsync(
} else {
future.complete(null);
}
})
.exceptionally(throwable -> {
future.completeExceptionally(getApiException(throwable));
return null;
});
} catch (Exception e) {
future.completeExceptionally(getApiException(e));
Expand Down Expand Up @@ -755,6 +763,10 @@ public CompletableFuture<Void> uploadFunctionAsync(String sourceFile, String pat
} else {
future.complete(null);
}
})
.exceptionally(throwable -> {
future.completeExceptionally(getApiException(throwable));
return null;
});
} catch (Exception e) {
future.completeExceptionally(getApiException(e));
Expand Down Expand Up @@ -844,24 +856,29 @@ public void onThrowable(Throwable t) {
}
}).toCompletableFuture();

statusFuture.thenAccept(status -> {
try {
os.close();
} catch (Exception e) {
future.completeExceptionally(getApiException(e));
return;
}

if (status.getStatusCode() < 200 || status.getStatusCode() >= 300) {
future.completeExceptionally(
getApiException(Response
.status(status.getStatusCode())
.entity(status.getStatusText())
.build()));
} else {
future.complete(null);
}
});
statusFuture
.thenAccept(status -> {
try {
os.close();
} catch (Exception e) {
future.completeExceptionally(getApiException(e));
return;
}

if (status.getStatusCode() < 200 || status.getStatusCode() >= 300) {
future.completeExceptionally(
getApiException(Response
.status(status.getStatusCode())
.entity(status.getStatusText())
.build()));
} else {
future.complete(null);
}
})
.exceptionally(throwable -> {
future.completeExceptionally(getApiException(throwable));
return null;
});
} catch (Exception e) {
future.completeExceptionally(getApiException(e));
}
Expand Down Expand Up @@ -978,6 +995,10 @@ public CompletableFuture<Void> putFunctionStateAsync(
} else {
future.complete(null);
}
})
.exceptionally(throwable -> {
future.completeExceptionally(getApiException(throwable));
return null;
});

} catch (Exception e) {
Expand Down Expand Up @@ -1025,6 +1046,10 @@ public CompletableFuture<Void> updateOnWorkerLeaderAsync(String tenant, String n
} else {
future.complete(null);
}
})
.exceptionally(throwable -> {
future.completeExceptionally(getApiException(throwable));
return null;
});

} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ public CompletableFuture<Void> createSinkAsync(SinkConfig sinkConfig, String fil
} else {
future.complete(null);
}
})
.exceptionally(throwable -> {
future.completeExceptionally(getApiException(throwable));
return null;
});
} catch (Exception e) {
future.completeExceptionally(getApiException(e));
Expand Down Expand Up @@ -358,6 +362,10 @@ public CompletableFuture<Void> updateSinkAsync(
} else {
future.complete(null);
}
})
.exceptionally(throwable -> {
future.completeExceptionally(getApiException(throwable));
return null;
});
} catch (Exception e) {
future.completeExceptionally(getApiException(e));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ public CompletableFuture<Void> createSourceAsync(SourceConfig sourceConfig, Stri
} else {
future.complete(null);
}
})
.exceptionally(throwable -> {
future.completeExceptionally(getApiException(throwable));
return null;
});
} catch (Exception e) {
future.completeExceptionally(getApiException(e));
Expand Down Expand Up @@ -360,6 +364,10 @@ public CompletableFuture<Void> updateSourceAsync(
} else {
future.complete(null);
}
})
.exceptionally(throwable -> {
future.completeExceptionally(getApiException(throwable));
return null;
});
} catch (Exception e) {
future.completeExceptionally(getApiException(e));
Expand Down

0 comments on commit 77ea9b8

Please sign in to comment.