Fix call sync method in async rest api for internalCreateSubscription.
@@ -2086,16 +2086,13 @@ public class PersistentTopicsBase extends AdminResource {
protected void internalCreateSubscription(AsyncResponse asyncResponse, String subscriptionName,
MessageIdImpl messageId, boolean authoritative, boolean replicated) {
+ CompletableFuture<Void> ret;
if (topicName.isGlobal()) {
- try {
- validateGlobalNamespaceOwnership(namespaceName);
- } catch (Exception e) {
- log.error("[{}] Failed to create subscription {} on topic {}",
- clientAppId(), subscriptionName, topicName, e);
- resumeAsyncResponseExceptionally(asyncResponse, e);
- return;
- }
+ ret = validateGlobalNamespaceOwnershipAsync(namespaceName);
+ } else {
+ ret = CompletableFuture.completedFuture(null);
}
+ ret.thenAccept(__ -> {
final MessageIdImpl targetMessageId = messageId == null ? (MessageIdImpl) MessageId.latest : messageId;
log.info("[{}][{}] Creating subscription {} at message id {}", clientAppId(), topicName, subscriptionName,
targetMessageId);
@@ -2183,6 +2180,7 @@ public class PersistentTopicsBase extends AdminResource {
return null;
});
}
+ });
}
private void internalCreateSubscriptionForNonPartitionedTopic(
