Skip to content

Commit

Permalink
returning CompletableFuture<Void>
Browse files Browse the repository at this point in the history
  • Loading branch information
315157973 committed Jan 10, 2023
1 parent eeb8502 commit f5ba93c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4655,8 +4655,8 @@ protected void internalGetLastMessageId(AsyncResponse asyncResponse, boolean aut
return null;
});
}
protected void internalTrimTopic(AsyncResponse asyncResponse, boolean authoritative) {
validateTopicOwnershipAsync(topicName, authoritative)
protected CompletableFuture<Void> internalTrimTopic(AsyncResponse asyncResponse, boolean authoritative) {
return validateTopicOwnershipAsync(topicName, authoritative)
.thenCompose(__ -> validateTopicOperationAsync(topicName, TopicOperation.TRIM_TOPIC))
.thenCompose(__ -> pulsar().getBrokerService().fetchPartitionedTopicMetadataAsync(topicName))
.thenCompose(metadata -> {
Expand All @@ -4673,13 +4673,6 @@ protected void internalTrimTopic(AsyncResponse asyncResponse, boolean authoritat
return trimPartitionedTopic(asyncResponse, metadata);
}
return trimNonPartitionedTopic(asyncResponse, topicName);
}).exceptionally(ex -> {
// If the exception is not redirect exception we need to log it.
if (!isRedirectException(ex)) {
log.error("[{}] Failed to trim topic {}", clientAppId(), topicName, ex);
}
resumeAsyncResponseExceptionally(asyncResponse, ex);
return null;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3292,7 +3292,14 @@ public void trimTopic(
@QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
try {
validateTopicName(tenant, namespace, encodedTopic);
internalTrimTopic(asyncResponse, authoritative);
internalTrimTopic(asyncResponse, authoritative).exceptionally(ex -> {
// If the exception is not redirect exception we need to log it.
if (!isRedirectException(ex)) {
log.error("[{}] Failed to trim topic {}", clientAppId(), topicName, ex);
}
resumeAsyncResponseExceptionally(asyncResponse, ex);
return null;
});
} catch (Exception e) {
asyncResponse.resume(new RestException(e));
}
Expand Down

0 comments on commit f5ba93c

Please sign in to comment.