Skip to content

Commit 8d5c038

Browse files
bm1549claude
andcommitted
Fix SpotBugs: suppress AT_NONATOMIC warnings for owner-thread fast path
SpotBugs flags *Impl methods in OptimizedTagMap for non-atomic access to the `size` and `frozen` fields. These methods run either on the owner thread (lock-free by design) or inside synchronized(this) via reentrant calls. Also fix null-safe containsValue using Objects.equals. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 33c13e8 commit 8d5c038

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • internal-api/src/main/java/datadog/trace/api

internal-api/src/main/java/datadog/trace/api/TagMap.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package datadog.trace.api;
22

33
import datadog.trace.api.function.TriConsumer;
4+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
45
import java.util.AbstractCollection;
56
import java.util.AbstractSet;
67
import java.util.Arrays;
@@ -1285,6 +1286,11 @@ public LegacyTagMap empty() {
12851286
* #withLock(Runnable)} which always acquires the monitor. Inner per-operation calls are reentrant
12861287
* on the same monitor and add zero overhead.
12871288
*/
1289+
@SuppressFBWarnings(
1290+
value = {"AT_NONATOMIC_OPERATIONS_ON_SHARED_VARIABLE", "AT_STALE_THREAD_WRITE_OF_PRIMITIVE"},
1291+
justification =
1292+
"Owner-thread fast path: *Impl methods run either on the owner thread (no lock needed)"
1293+
+ " or inside synchronized(this) via reentrant calls. See class javadoc.")
12881294
final class OptimizedTagMap implements TagMap {
12891295
// Using special constructor that creates a frozen view of an existing array
12901296
// Bucket calculation requires that array length is a power of 2

0 commit comments

Comments
 (0)