Skip to content

Commit b81fcdc

Browse files
committed
Merge branch 'feat/unhandled-sessions-protocol' into feat/unhandled-sessions-cache
2 parents f8fee2b + 398f0eb commit b81fcdc

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎sentry/src/main/java/io/sentry/Session.java‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ public boolean hasNonTerminatingUnhandledError() {
213213
/**
214214
* Records that an active session experienced an unhandled error which did not terminate the
215215
* process, counting the error and advancing the session's sequence without ending it. On {@link
216-
* #end()} the session is finalized as {@link State#Unhandled} unless a crash escalated it to
217-
* {@link State#Crashed} first.
216+
* #end()} the session is finalized as {@link State#Unhandled} unless a terminal status such as
217+
* {@link State#Crashed} or {@link State#Abnormal} took over first.
218218
*
219219
* <p>Hybrid SDKs whose unhandled errors do not kill the process. Native Java/Android capture
220220
* should not call this.
@@ -310,8 +310,9 @@ public boolean update(
310310
boolean sessionHasBeenUpdated = false;
311311
if (status != null) {
312312
this.status = status;
313-
// a crash terminates the process, so it takes precedence over a non-terminating one.
314-
if (status == State.Crashed) {
313+
// the flag only decides how an Ok session is finalized, so an explicit terminal status
314+
// such as a crash or an ANR takes precedence over a non-terminating error.
315+
if (status != State.Ok) {
315316
hasNonTerminatingUnhandledError = false;
316317
}
317318
sessionHasBeenUpdated = true;

‎sentry/src/test/java/io/sentry/cache/EnvelopeCacheTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ class EnvelopeCacheTest {
531531
)
532532
assertEquals(State.Abnormal, updatedSession!!.status)
533533
assertEquals("abnormal_mechanism", updatedSession.abnormalMechanism)
534-
assertTrue(updatedSession.hasNonTerminatingUnhandledError())
534+
assertFalse(updatedSession.hasNonTerminatingUnhandledError())
535535
}
536536

537537
@Test

‎sentry/src/test/java/io/sentry/protocol/SessionSerializationTest.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class SessionSerializationTest {
3939
/**
4040
* An unhandled session cannot be built by mutating [getSut]: the flag is only reachable through
4141
* [Session.recordNonTerminatingUnhandledError], which no-ops unless the session is still `Ok`,
42-
* and a crash would clear it again. Ending on a fixed timestamp keeps `seq` and `duration`
43-
* deterministic.
42+
* and a terminal status would clear it again. Ending on a fixed timestamp keeps `seq` and
43+
* `duration` deterministic.
4444
*/
4545
fun getUnhandledSut() =
4646
Session(

0 commit comments

Comments
 (0)