Skip to content

Commit 03d997e

Browse files
authored
Fixing oversight of missing synchronized on long version of recalibrate (#9480)
* Fixing oversight of missing synchronized on long version of recalibrate * Adding spotbugs suppression The racy updates of cache stat fields is deliberate -- and that's the cause of the inconsistent sync-ing * spotless * Removing leftover SIZE variable
1 parent 3ff796a commit 03d997e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

dd-trace-core/src/main/java/datadog/trace/common/writer/ddagent/GenerationalUtf8Cache.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import datadog.communication.serialization.EncodingCache;
44
import datadog.trace.common.writer.ddagent.SimpleUtf8Cache.CacheEntry;
5+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
56
import java.nio.charset.StandardCharsets;
67

78
/**
@@ -63,6 +64,10 @@
6364
* calling ValueUtf8Cache#reclibrate will adjust promotion thresholds to
6465
* provide better cache utilization.
6566
*/
67+
@SuppressFBWarnings(
68+
value = "IS2_INCONSISTENT_SYNC",
69+
justification =
70+
"stat updates are deliberately racy - sync is only used to prevent simultaneous bulk updates")
6671
public final class GenerationalUtf8Cache implements EncodingCache {
6772
static final int MAX_EDEN_CAPACITY = 512;
6873
static final int MAX_TENURED_CAPACITY = 1024;
@@ -156,7 +161,7 @@ public synchronized void recalibrate() {
156161
*
157162
* <p>While still racy this method is synchronized to avoid simultaneous recalibrations
158163
*/
159-
public void recalibrate(long accessTimeMs) {
164+
public synchronized void recalibrate(long accessTimeMs) {
160165
this.accessTimeMs = accessTimeMs;
161166

162167
recalibrate(this.edenEntries);

dd-trace-core/src/main/java/datadog/trace/common/writer/ddagent/SimpleUtf8Cache.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ public final class SimpleUtf8Cache implements EncodingCache {
4747

4848
private static final int MAX_PROBES = 4;
4949

50-
private final int SIZE = 64;
51-
5250
private final int[] markers;
5351
private final CacheEntry[] entries;
5452

0 commit comments

Comments
 (0)