diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index c04a3f9a2c..0cdeb84dbe 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -34,6 +34,7 @@ Use subheadings with the "=====" level for adding notes for unreleased changes: [float] ===== Bug fixes * Fixed edge case where inferred spans could cause cycles in the trace parent-child relationships, subsequently resulting in the UI crashing - {pull}3588[#3588] +* Fix NPE in dropped spans statistics - {pull}3590[#3590] [[release-notes-1.x]] === Java Agent version 1.x diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/DroppedSpanStats.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/DroppedSpanStats.java index ff25b9596b..74bcf45c95 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/DroppedSpanStats.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/DroppedSpanStats.java @@ -190,10 +190,13 @@ public void captureDroppedSpan(Span span) { private Stats getOrCreateStats(ServiceTarget serviceTarget, Outcome outcome) { StatsKey statsKey = statsKeyObjectPool.createInstance().init(serviceTarget, outcome); Stats stats = statsMap.get(statsKey); - if (stats != null || statsMap.size() > 127) { + if (stats != null) { statsKeyObjectPool.recycle(statsKey); return stats; } + if (statsMap.size() > 127) { + statsKeyObjectPool.recycle(statsKey); + } stats = statsObjectPool.createInstance();