codelipenghui commented on code in PR #18194:
URL: https://github.com/apache/pulsar/pull/18194#discussion_r1006357107


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java:
##########
@@ -822,8 +822,12 @@ protected void 
validateGlobalNamespaceOwnership(NamespaceName namespace) {
         } catch (WebApplicationException e) {
             throw e;
         } catch (Exception e) {
-            if (e.getCause() instanceof WebApplicationException) {
-                throw (WebApplicationException) e.getCause();
+            Throwable throwable = FutureUtil.unwrapCompletionException(e);
+            if (throwable instanceof WebApplicationException 
webApplicationException) {
+                throw webApplicationException;
+            }
+            if (throwable instanceof RestException restException){
+                throw restException;

Review Comment:
   We can remove these lines.
   The `RestException` is a sub-class of `WebApplicationException`



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java:
##########
@@ -875,7 +879,7 @@ public static CompletableFuture<ClusterDataImpl> 
checkLocalOrGetPeerReplicationC
                 if (!allowDeletedNamespace && policies.deleted) {
                     String msg = String.format("Namespace %s is deleted", 
namespace.toString());
                     log.warn(msg);
-                    validationFuture.completeExceptionally(new 
RestException(Status.PRECONDITION_FAILED,
+                    validationFuture.completeExceptionally(new 
RestException(Status.NOT_FOUND,

Review Comment:
   It's incorrect here.
   If `allowDeletedNamespace` is false. We should return 
`Status.PRECONDITION_FAILED`. No matter if `policies.deleted` is true or false.



-- 
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]

Reply via email to