File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments