You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zipkin.apache.org by an...@apache.org on 2019/05/28 08:08:28 UTC
[incubator-zipkin] branch master updated: Handle exceptions without
message. (#2611)
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 <an...@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);
}
}