Skip to content

Commit 960c618

Browse files
docs(android): Record why the session persist sits inside withSession
Three reviewers in a row read the persist as accidentally holding the scope lock, so say why it is deliberate. Also name abnormal alongside crashed as a terminal status that wins over the unhandled marker, following the Session javadoc. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c1cbf99 commit 960c618

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎sentry-android-core/src/main/java/io/sentry/android/core/InternalSentrySdk.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ public static SentryId captureEnvelope(
225225
* </ul>
226226
*
227227
* <p>The session is finalized later by normal lifecycle ({@code endSession} / background /
228-
* previous-session recovery) as {@code unhandled}, unless a native crash escalates it to {@code
229-
* crashed}.
228+
* previous-session recovery) as {@code unhandled}, unless a terminal status takes over first,
229+
* such as {@code crashed} for a native crash or {@code abnormal} for an ANR.
230230
*
231231
* <p>Same as {@link #captureEnvelope(byte[], boolean)}, this method will not enrich events, run
232232
* {@code beforeSend}, or sample — the caller is responsible for that.
@@ -251,6 +251,9 @@ public static SentryId captureEnvelopeNonTerminating(final @NotNull byte[] envel
251251
if (eventState != EnvelopeEventState.NONE) {
252252
scopes.configureScope(
253253
scope -> {
254+
// the write stays inside the callback so the mutation and the persist are one
255+
// critical section. Persisting outside it lets a concurrent caller's older snapshot
256+
// land last and drop the unhandled marker.
254257
scope.withSession(
255258
session -> {
256259
if (session != null) {

0 commit comments

Comments
 (0)