zhaizhibo commented on code in PR #25626:
URL: https://github.com/apache/pulsar/pull/25626#discussion_r3174604269
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java:
##########
@@ -596,77 +595,72 @@ protected NamespaceBundle
validateNamespaceBundleRange(NamespaceName fqnn, Bundl
(upperEndpoint.equals(NamespaceBundles.FULL_UPPER_BOUND))
? BoundType.CLOSED : BoundType.OPEN);
NamespaceBundle nsBundle =
pulsar().getNamespaceService().getNamespaceBundleFactory().getBundle(fqnn,
hashRange);
- NamespaceBundles nsBundles =
pulsar().getNamespaceService().getNamespaceBundleFactory().getBundles(fqnn,
- bundles);
- nsBundles.validateBundle(nsBundle);
- return nsBundle;
+ return
pulsar().getNamespaceService().getNamespaceBundleFactory().getBundlesAsync(fqnn)
+ .thenApply(nsBundles -> {
+ try {
+ nsBundles.validateBundle(nsBundle);
+ return nsBundle;
+ } catch (IllegalArgumentException e) {
+ log.error()
+ .attr("namespace", fqnn.toString())
+ .attr("bundleRange", bundleRange)
+ .exceptionMessage(e)
+ .log("Invalid bundle range");
+ throw new
RestException(Response.Status.PRECONDITION_FAILED, e.getMessage());
+ } catch (Exception e) {
+ log.error()
+ .attr("namespace", fqnn.toString())
+ .attr("bundleRange", bundleRange)
+ .exception(e)
+ .log("Failed to validate namespace
bundle");
+ throw new RestException(e);
+ }
+ });
} catch (IllegalArgumentException e) {
log.error()
.attr("namespace", fqnn.toString())
.attr("bundleRange", bundleRange)
.exceptionMessage(e)
.log("Invalid bundle range");
- throw new RestException(Response.Status.PRECONDITION_FAILED,
e.getMessage());
+ return CompletableFuture.failedFuture(
+ new RestException(Response.Status.PRECONDITION_FAILED,
e.getMessage()));
+ } catch (RestException e) {
+ return CompletableFuture.failedFuture(e);
Review Comment:
I have already removed these redundant code.
--
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]