HttpHandler { void handleFinish(HttpResponse response, Span span) { if (response == null) throw new NullPointerException("response == null"); if (span == null) throw new NullPointerException("span == null"); if (span.isNoop()) return; if (response.error() != null) { span.error(response.error()); } try { parseResponse(response, span); } catch (Throwable t) { propagateIfFatal(t); Platform.get().log("error parsing response {0}", response, t); } finally { long finishTimestamp = response.finishTimestamp(); if (finishTimestamp == 0L) { span.finish(); } else { span.finish(finishTimestamp); } } } HttpHandler(HttpRequestParser requestParser, HttpResponseParser responseParser);   }
@Test public void handleFinish_nothingOnNoop() { when(span.isNoop()).thenReturn(true); handler.handleFinish(response, span); verify(span, never()).finish(); }
@Test public void handleFinish_parsesTagsWithCustomizer() { when(span.customizer()).thenReturn(spanCustomizer); handler.handleFinish(response, span); verify(responseParser).parse(response, context, spanCustomizer); }
@Test public void handleFinish_errorRecordedInSpan() { RuntimeException error = new RuntimeException("foo"); when(response.error()).thenReturn(error); handler.handleFinish(response, span); verify(span).error(error); }
@Test public void handleFinish_finishedEvenIfParsingThrows() { when(span.isNoop()).thenReturn(false); doThrow(new RuntimeException()).when(responseParser).parse(response, context, spanCustomizer); handler.handleFinish(response, span); verify(span).finish(); }