zipkin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anura...@apache.org
Subject [incubator-zipkin] branch master updated: Handle exceptions without message. (#2611)
Date Tue, 28 May 2019 08:08:28 GMT
This is an automated email from the ASF dual-hosted git repository.

anuraaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-zipkin.git


The following commit(s) were added to refs/heads/master by this push:
     new aeedd6e  Handle exceptions without message. (#2611)
aeedd6e is described below

commit aeedd6e1ecb772676b93a7275afbfac3315b0848
Author: Anuraag Agrawal <anuraaga@gmail.com>
AuthorDate: Tue May 28 17:08:18 2019 +0900

    Handle exceptions without message. (#2611)
    
    * Handle exceptions without message.
    
    * Only log on not bad request.
---
 .../main/java/zipkin2/server/internal/ZipkinHttpCollector.java | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinHttpCollector.java
b/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinHttpCollector.java
index 60d0807..d19533b 100644
--- a/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinHttpCollector.java
+++ b/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinHttpCollector.java
@@ -235,13 +235,19 @@ final class UnzippingBytesRequestConverter {
 
 final class BodyIsExceptionMessage implements ExceptionHandlerFunction {
 
+  static final Logger LOGGER = LogManager.getLogger();
+
   @Override
   public HttpResponse handleException(RequestContext ctx, HttpRequest req, Throwable cause)
{
     ZipkinHttpCollector.metrics.incrementMessagesDropped();
+
+    String message = cause.getMessage() != null ? cause.getMessage() : "";
     if (cause instanceof IllegalArgumentException) {
-      return HttpResponse.of(BAD_REQUEST, MediaType.ANY_TEXT_TYPE, cause.getMessage());
+      return HttpResponse.of(BAD_REQUEST, MediaType.ANY_TEXT_TYPE, message);
     } else {
-      return HttpResponse.of(INTERNAL_SERVER_ERROR, MediaType.ANY_TEXT_TYPE, cause.getMessage());
+      LOGGER.warn("Unexpected error handling request.", cause);
+
+      return HttpResponse.of(INTERNAL_SERVER_ERROR, MediaType.ANY_TEXT_TYPE, message);
     }
   }
 


Mime
View raw message