Technoboy- commented on code in PR #15621:
URL: https://github.com/apache/pulsar/pull/15621#discussion_r875401926


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Namespaces.java:
##########
@@ -543,14 +550,25 @@ public void setAutoTopicCreation(@Suspended final 
AsyncResponse asyncResponse,
                                      @PathParam("property") String property, 
@PathParam("cluster") String cluster,
                                      @PathParam("namespace") String namespace,
                                      AutoTopicCreationOverride 
autoTopicCreationOverride) {
-        try {
-            validateNamespaceName(property, cluster, namespace);
-            internalSetAutoTopicCreation(asyncResponse, 
autoTopicCreationOverride);
-        } catch (RestException e) {
-            asyncResponse.resume(e);
-        } catch (Exception e) {
-            asyncResponse.resume(new RestException(e));
-        }
+        validateNamespaceName(property, cluster, namespace);
+        internalSetAutoTopicCreationAsync(autoTopicCreationOverride)
+                .thenAccept(__ -> {
+                    String autoOverride = (autoTopicCreationOverride != null
+                            && 
autoTopicCreationOverride.isAllowAutoTopicCreation()) ? "enabled" : "disabled";
+                    log.info("[{}] Successfully {} autoTopicCreation on 
namespace {}", clientAppId(),
+                                                                               
          autoOverride, namespaceName);
+                    asyncResponse.resume(Response.noContent().build());
+                })
+                .exceptionally(e -> {
+                    log.error("[{}] Failed to set autoTopicCreation status on 
namespace {}", clientAppId(),
+                            namespaceName,
+                            e.getCause());
+                    if (e.getCause() instanceof NotFoundException) {
+                        asyncResponse.resume(new 
RestException(Status.NOT_FOUND, "Namespace does not exist"));
+                    }

Review Comment:
   Need else here.



-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to