lhotari commented on code in PR #24313:
URL: https://github.com/apache/pulsar/pull/24313#discussion_r2093431495
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java:
##########
@@ -568,33 +580,37 @@ protected void
internalCreatePartitionedTopic(AsyncResponse asyncResponse, int n
return;
}
validateNamespaceOperationAsync(topicName.getNamespaceObject(),
NamespaceOperation.CREATE_TOPIC)
- .thenRun(() -> {
- Policies policies = null;
- try {
- policies = getNamespacePolicies(namespaceName);
- } catch (RestException e) {
- if (e.getResponse().getStatus() !=
Status.NOT_FOUND.getStatusCode()) {
- throw e;
+ .thenCompose((__) ->
getNamespacePoliciesAsync(namespaceName).exceptionally(ex -> {
+ Throwable unwrapped =
FutureUtil.unwrapCompletionException(ex);
+ if (unwrapped instanceof RestException re) {
+ if (re.getResponse().getStatus() ==
Status.NOT_FOUND.getStatusCode()) {
+ return null;
}
}
-
+ throw new CompletionException(unwrapped);
Review Comment:
could use `throw FutureUtil.wrapToCompletionException(ex);` instead. There
wouldn't be a need to create a new `CompletionException` when it's already a
CompletionException.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]