From 302b54c2cb20240f91f54501b1335d986133ef15 Mon Sep 17 00:00:00 2001 From: Tommy Ludwig <8924140+shakuzen@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:38:19 +0900 Subject: [PATCH] Avoid encoding list of spans twice in BaseHttpSender (#270) newBody was called twice which would result in encoding the list of spans twice unnecessarily. This change will reduce allocations and copying memory. --- core/src/main/java/zipkin2/reporter/BaseHttpSender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/zipkin2/reporter/BaseHttpSender.java b/core/src/main/java/zipkin2/reporter/BaseHttpSender.java index fddfdd5a..709c3cef 100644 --- a/core/src/main/java/zipkin2/reporter/BaseHttpSender.java +++ b/core/src/main/java/zipkin2/reporter/BaseHttpSender.java @@ -120,7 +120,7 @@ final U nextEndpoint(HttpEndpointSupplier endpointSupplier) { if (endpoint == null) endpoint = nextEndpoint(endpointSupplier); B body = newBody(encodedSpans); if (body == null) throw new NullPointerException("newBody(encodedSpans) returned null"); - postSpans(endpoint, newBody(encodedSpans)); + postSpans(endpoint, body); } @Override public final void close() {