From ae700b6ba7405a4aa55531219a23f480d1e04271 Mon Sep 17 00:00:00 2001 From: Sylvain Juge <763082+SylvainJuge@users.noreply.github.com> Date: Thu, 18 Apr 2024 21:42:15 +0200 Subject: [PATCH 1/2] fix npe --- .../elastic/apm/agent/impl/transaction/DroppedSpanStats.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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(); From 576cd87d173405c8d75c303c72c8fbf69a04059e Mon Sep 17 00:00:00 2001 From: Sylvain Juge <763082+SylvainJuge@users.noreply.github.com> Date: Thu, 2 May 2024 10:22:27 +0200 Subject: [PATCH 2/2] update changelog --- CHANGELOG.asciidoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 44b9c2f8e5..74c1816595 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -31,6 +31,10 @@ Use subheadings with the "=====" level for adding notes for unreleased changes: === Unreleased +[float] +===== Bug fixes +* Fix NPE in dropped spans statistics - {pull}3590[#3590] + [[release-notes-1.x]] === Java Agent version 1.x