From 4369adeaba490b12cd79468aed77d30772b92d2b Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Thu, 11 Apr 2024 20:47:06 -0400 Subject: [PATCH] Minor formatting fixes and code simplification Signed-off-by: Andriy Redko --- .../reporter/internal/CountBoundedQueue.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/zipkin2/reporter/internal/CountBoundedQueue.java b/core/src/main/java/zipkin2/reporter/internal/CountBoundedQueue.java index 85c35170..2127d5fe 100644 --- a/core/src/main/java/zipkin2/reporter/internal/CountBoundedQueue.java +++ b/core/src/main/java/zipkin2/reporter/internal/CountBoundedQueue.java @@ -117,18 +117,14 @@ int doDrain(SpanWithSizeConsumer consumer) { metrics.incrementSpanBytes(nextSizeInBytes); if (messageSizeOfNextSpan > messageMaxBytes) { - drainedCount++; - metrics.incrementSpansDropped(1); - elements[readPos] = null; // should have been dropped before - if (++readPos == elements.length) readPos = 0; // circle back to the front of the array - } else if (consumer.offer(next, nextSizeInBytes)) { - drainedCount++; - - elements[readPos] = null; - if (++readPos == elements.length) readPos = 0; // circle back to the front of the array - } else { + metrics.incrementSpansDropped(1); + } else if (!consumer.offer(next, nextSizeInBytes)) { break; } + + drainedCount++; + elements[readPos] = null; + if (++readPos == elements.length) readPos = 0; // circle back to the front of the array } count -= drainedCount; return drainedCount;