Skip to content

refactor(core): Consolidate PersistingScopeObserver error handling#5692

Draft
runningcode wants to merge 1 commit into
mainfrom
no/java-608-serialize-runnable-churn
Draft

refactor(core): Consolidate PersistingScopeObserver error handling#5692
runningcode wants to merge 1 commit into
mainfrom
no/java-608-serialize-runnable-churn

Conversation

@runningcode

Copy link
Copy Markdown
Contributor

Resolves JAVA-608.

Description

PersistingScopeObserver.serializeToDisk duplicated the same try/catch error-handling block in both the on-executor path and the submit wrapper. This extracts it into a single runSafely(task) helper used by both.

⚠️ Honest scope note

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:

  • changing all ~12 call-site signatures so serializeToDisk no longer takes a bare Runnable (bigger refactor), or
  • submitting the raw task and relocating error logging (behavior change).

So 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

@linear-code

linear-code Bot commented Jul 2, 2026

Copy link
Copy Markdown

JAVA-608

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>
@runningcode runningcode force-pushed the no/java-608-serialize-runnable-churn branch from 5946bb5 to 31e6c7f Compare July 2, 2026 16:57
@sentry

sentry Bot commented Jul 2, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.47.0 (1) release

⚙️ sentry-android Build Distribution Settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant