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 2021/09/23 08:47:42 UTC

[GitHub] [pulsar] nodece opened a new pull request #12155: Improve exceptions thrown when handling the schema resource

nodece opened a new pull request #12155:
URL: https://github.com/apache/pulsar/pull/12155


   Signed-off-by: Zixuan Liu <no...@gmail.com>
   
   Fixes #12010, #10694
   
   ### Motivation
   
   When handing the schema resource, if an error occurs, there are no more error message responses, and the client only knows that the server returns 500 internal errors without the more helpful error message.
   
   ### Documentation
   
   Check the box below and label this PR (if you have committer privilege).
   
   Need to update docs? 
   
   - [ ] doc-required   
   - [x] no-need-doc 
   This PR only improves throwing error messages when an error occurs.
   - [ ] doc 
   
   
   
   


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



[GitHub] [pulsar] nodece commented on pull request #12155: [Broker] Improve exceptions thrown when handling the schema resource

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #12155:
URL: https://github.com/apache/pulsar/pull/12155#issuecomment-927235351


   /pulsarbot run-failure-checks


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



[GitHub] [pulsar] nodece commented on a change in pull request #12155: [Broker] Improve exceptions thrown when handling the schema resource

Posted by GitBox <gi...@apache.org>.
nodece commented on a change in pull request #12155:
URL: https://github.com/apache/pulsar/pull/12155#discussion_r714778891



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java
##########
@@ -177,20 +177,13 @@ public void postSchema(PostSchemaPayload payload, boolean authoritative, AsyncRe
                                     error.getMessage()).build());
                         } else {
                             log.error("[{}] Failed to post schema for topic {}", clientAppId(), topicName, error);
-                            response.resume(Response.serverError().build());
+                            response.resume(new RestException(error));
                         }
                         return null;
                     });
         }).exceptionally(error -> {
-            if (error.getCause() instanceof RestException) {
-                // Unprocessable Entity
-                response.resume(Response
-                        .status(((RestException) error.getCause()).getResponse().getStatus(), error.getMessage())
-                        .build());
-            } else {
-                log.error("[{}] Failed to post schema for topic {}", clientAppId(), topicName, error);
-                response.resume(Response.serverError().build());
-            }
+            log.error("[{}] Failed to post schema for topic {}", clientAppId(), topicName, error);
+            response.resume(new RestException(error));

Review comment:
       Good catch.




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



[GitHub] [pulsar] nodece commented on pull request #12155: [Broker] Improve exceptions thrown when handling the schema resource

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #12155:
URL: https://github.com/apache/pulsar/pull/12155#issuecomment-929814374


   /pulsarbot run-failure-checks


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



[GitHub] [pulsar] nodece commented on pull request #12155: [Broker] Improve exceptions thrown when handling the schema resource

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #12155:
URL: https://github.com/apache/pulsar/pull/12155#issuecomment-926281757


   /pulsarbot run-failure-checks
   
   


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



[GitHub] [pulsar] nodece commented on pull request #12155: [Broker] Improve exceptions thrown when handling the schema resource

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #12155:
URL: https://github.com/apache/pulsar/pull/12155#issuecomment-927243461


   /pulsarbot run-failure-checks


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



[GitHub] [pulsar] nodece commented on pull request #12155: [Broker] Improve exceptions thrown when handling the schema resource

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #12155:
URL: https://github.com/apache/pulsar/pull/12155#issuecomment-929814374


   /pulsarbot run-failure-checks


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



[GitHub] [pulsar] codelipenghui merged pull request #12155: [Broker] Improve exceptions thrown when handling the schema resource

Posted by GitBox <gi...@apache.org>.
codelipenghui merged pull request #12155:
URL: https://github.com/apache/pulsar/pull/12155


   


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



[GitHub] [pulsar] nodece commented on pull request #12155: [Broker] Improve exceptions thrown when handling the schema resource

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #12155:
URL: https://github.com/apache/pulsar/pull/12155#issuecomment-927662657


   /pulsarbot run-failure-checks


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



[GitHub] [pulsar] RobertIndie commented on a change in pull request #12155: [Broker] Improve exceptions thrown when handling the schema resource

Posted by GitBox <gi...@apache.org>.
RobertIndie commented on a change in pull request #12155:
URL: https://github.com/apache/pulsar/pull/12155#discussion_r714775482



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java
##########
@@ -177,20 +177,13 @@ public void postSchema(PostSchemaPayload payload, boolean authoritative, AsyncRe
                                     error.getMessage()).build());
                         } else {
                             log.error("[{}] Failed to post schema for topic {}", clientAppId(), topicName, error);
-                            response.resume(Response.serverError().build());
+                            response.resume(new RestException(error));
                         }
                         return null;
                     });
         }).exceptionally(error -> {
-            if (error.getCause() instanceof RestException) {
-                // Unprocessable Entity
-                response.resume(Response
-                        .status(((RestException) error.getCause()).getResponse().getStatus(), error.getMessage())
-                        .build());
-            } else {
-                log.error("[{}] Failed to post schema for topic {}", clientAppId(), topicName, error);
-                response.resume(Response.serverError().build());
-            }
+            log.error("[{}] Failed to post schema for topic {}", clientAppId(), topicName, error);
+            response.resume(new RestException(error));

Review comment:
       This seems to overwrite the status of the RestException thrown by the upper layer.




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



[GitHub] [pulsar] nodece commented on pull request #12155: [Broker] Improve exceptions thrown when handling the schema resource

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #12155:
URL: https://github.com/apache/pulsar/pull/12155#issuecomment-925766022


   /pulsarbot run-failure-checks
   
   


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



[GitHub] [pulsar] nodece commented on pull request #12155: [Broker] Improve exceptions thrown when handling the schema resource

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #12155:
URL: https://github.com/apache/pulsar/pull/12155#issuecomment-927257993


   /pulsarbot run-failure-checks


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



[GitHub] [pulsar] nodece commented on pull request #12155: [Broker] Improve exceptions thrown when handling the schema resource

Posted by GitBox <gi...@apache.org>.
nodece commented on pull request #12155:
URL: https://github.com/apache/pulsar/pull/12155#issuecomment-927222438


   /pulsarbot run-failure-checks


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