From 6dde6e492219d9da8aaec082391711368cc66c79 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Sat, 24 Aug 2019 20:38:43 +0900 Subject: [PATCH] Catch and return all possible errors in collector. (#2782) --- .../zipkin2/server/internal/ZipkinHttpCollector.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 2bc36e8eecd..0c85892d82c 100644 --- a/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinHttpCollector.java +++ b/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinHttpCollector.java @@ -147,6 +147,9 @@ HttpResponse validateAndStoreSpans(SpanBytesDecoder decoder, ServiceRequestConte } catch (IllegalArgumentException e) { result.onError(new IllegalArgumentException("Expected a " + decoder + " encoded list\n")); return null; + } catch (Throwable t1) { + result.onError(t1); + return null; } SpanBytesDecoder unexpectedDecoder = testForUnexpectedFormat(decoder, nioBuffer); @@ -159,7 +162,12 @@ HttpResponse validateAndStoreSpans(SpanBytesDecoder decoder, ServiceRequestConte // collector.accept might block so need to move off the event loop. We make sure the // callback is context aware to continue the trace. Executor executor = ctx.makeContextAware(ctx.blockingTaskExecutor()); - collector.acceptSpans(nioBuffer, decoder, result, executor); + try { + collector.acceptSpans(nioBuffer, decoder, result, executor); + } catch (Throwable t1) { + result.onError(t1); + return null; + } } finally { ReferenceCountUtil.release(content); }