You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/03/09 06:33:17 UTC

[GitHub] [pulsar] nodece commented on a change in pull request #13535: [Broker] Throw a warning log when update a topic level policy on non-exist topic

nodece commented on a change in pull request #13535:
URL: https://github.com/apache/pulsar/pull/13535#discussion_r822326287



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -4554,10 +4555,28 @@ protected void internalGetLastMessageId(AsyncResponse asyncResponse, boolean aut
 
     protected void handleTopicPolicyException(String methodName, Throwable thr, AsyncResponse asyncResponse) {
         Throwable cause = thr.getCause();
-        if (!(cause instanceof WebApplicationException)
-                || !(((WebApplicationException) cause).getResponse().getStatus() == 307)) {
-            log.error("[{}] Failed to perform {} on topic {}",
-                    clientAppId(), methodName, topicName, cause);
+
+        Level logLevel = null;
+        if (cause instanceof WebApplicationException) {
+            int statusCode = ((WebApplicationException) cause).getResponse().getStatus();
+            if (statusCode == Status.NOT_FOUND.getStatusCode()) {
+                logLevel = Level.WARN;
+            } else if (statusCode != Status.TEMPORARY_REDIRECT.getStatusCode()) {
+                logLevel = Level.ERROR;
+            }
+        } else {
+            logLevel = Level.ERROR;
+        }
+
+        if (logLevel != null) {
+            switch (logLevel) {
+                case WARN:
+                    log.warn("[{}] Failed to perform {} on topic {}", clientAppId(), methodName, topicName, cause);

Review comment:
       Yes, we can avoid this. 




-- 
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-unsubscribe@pulsar.apache.org

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