Skip to content

Commit 8e472c5

Browse files
43jayclaude
andcommitted
fix(profiling): Use AtomicReference for metaLength to preserve nullable contract
AtomicInteger initialized to -1 would write meta_length: -1 if the header were serialized before the payload was materialized. Replace with AtomicReference<Integer> initialized to null so getMetaLength() correctly returns null before evaluation, matching the @nullable contract and causing serialize() to skip the field. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b3c71ce commit 8e472c5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sentry/src/main/java/io/sentry/SentryEnvelopeItem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import java.util.LinkedHashMap;
2929
import java.util.Map;
3030
import java.util.concurrent.Callable;
31-
import java.util.concurrent.atomic.AtomicInteger;
31+
import java.util.concurrent.atomic.AtomicReference;
3232
import org.jetbrains.annotations.ApiStatus;
3333
import org.jetbrains.annotations.NotNull;
3434
import org.jetbrains.annotations.Nullable;
@@ -390,7 +390,7 @@ private static void ensureAttachmentSizeLimit(
390390
// delimiter. The server needs meta_length in the envelope header to know where the JSON
391391
// ends and the binary begins. meta_length is not known until the CachedItem payload lambda
392392
// runs, so we track it here as an envelope serialization concern rather than on ProfileChunk.
393-
final AtomicInteger metaLength = new AtomicInteger(-1);
393+
final AtomicReference<Integer> metaLength = new AtomicReference<>(null);
394394

395395
final CachedItem cachedItem =
396396
new CachedItem(

0 commit comments

Comments
 (0)