Skip to content

Commit 3347255

Browse files
ref(session): Name the terminal-status check
`status != State.Ok` stated the mechanism while the comment carried the meaning. An isTerminal helper says it directly and reads the same in recordNonTerminatingUnhandledError, whose javadoc already spoke of terminal states. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 398f0eb commit 3347255

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public boolean hasNonTerminatingUnhandledError() {
224224
@ApiStatus.Internal
225225
public boolean recordNonTerminatingUnhandledError() {
226226
try (final @NotNull ISentryLifecycleToken ignored = sessionLock.acquire()) {
227-
if (status != State.Ok) {
227+
if (isTerminal(status)) {
228228
return false;
229229
}
230230
hasNonTerminatingUnhandledError = true;
@@ -310,9 +310,9 @@ public boolean update(
310310
boolean sessionHasBeenUpdated = false;
311311
if (status != null) {
312312
this.status = status;
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) {
313+
// the marker only decides how an Ok session is finalized, so a terminal status such as a
314+
// crash or an ANR takes precedence over a non-terminating error.
315+
if (isTerminal(status)) {
316316
hasNonTerminatingUnhandledError = false;
317317
}
318318
sessionHasBeenUpdated = true;
@@ -347,6 +347,11 @@ public boolean update(
347347
}
348348
}
349349

350+
/** A session can only leave {@link State#Ok}, every other status is final. */
351+
private static boolean isTerminal(final @NotNull State state) {
352+
return state != State.Ok;
353+
}
354+
350355
/**
351356
* Returns a logical clock.
352357
*

0 commit comments

Comments
 (0)