refactor(core): Consolidate PersistingScopeObserver error handling#5692
Draft
runningcode wants to merge 1 commit into
Draft
refactor(core): Consolidate PersistingScopeObserver error handling#5692runningcode wants to merge 1 commit into
runningcode wants to merge 1 commit into
Conversation
Extract the duplicated try/catch in PersistingScopeObserver.serializeToDisk into a single runSafely helper used by both the on-executor and submit paths. Pure internal cleanup; error-handling behavior is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
5946bb5 to
31e6c7f
Compare
📲 Install BuildsAndroid
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves JAVA-608.
Description
PersistingScopeObserver.serializeToDiskduplicated the same try/catch error-handling block in both the on-executor path and thesubmitwrapper. This extracts it into a singlerunSafely(task)helper used by both.The issue was originally framed as reducing lambda allocation churn (two
Runnables per persist: the call-site task + the submit wrapper). On closer inspection this refactor does not reduce the per-call allocation count — the submit path still allocates one wrapper (() -> runSafely(task)) plus the call-site task lambda, same as before. Genuinely eliminating the second allocation would require either:serializeToDiskno longer takes a bareRunnable(bigger refactor), orSo this PR is a pure internal cleanup (single error-handling code path), not a measurable performance win. Flagging so we can decide whether to (a) merge as cleanup, (b) expand into the call-site refactor, or (c) close. Kept as draft.
Source
Part of Reduce SDK init time [Android], from Perfetto method-trace analysis of the scope-persistence path.
🤖 Generated with Claude Code