Skip to content

ref(core): Inject the envelope disk cache from SentryRuntime - #6833

Draft
runningcode wants to merge 1 commit into
no/sentryruntime-foundationfrom
no/sentryruntime-disk-cache
Draft

runningcode wants to merge 1 commit into
no/sentryruntime-foundationfrom
no/sentryruntime-disk-cache

Conversation

@runningcode

Copy link
Copy Markdown
Contributor

📜 Description

The envelope disk cache now reaches its users through constructors instead of SentryOptions.getEnvelopeDiskCache().

before:  new SentryClient(options) ─► AsyncHttpTransportFactory() ─► reads options.getEnvelopeDiskCache()
after:   new SentryClient(options, runtime.cache) ─► AsyncHttpTransportFactory(cache) ─► AsyncHttpTransport(…, cache)
- new MovePreviousSession(options)
+ new MovePreviousSession(options, runtime.getEnvelopeDiskCache())
- new PreviousSessionFinalizer(options, scopes)
+ new PreviousSessionFinalizer(options, scopes, runtime.getEnvelopeDiskCache(), runtime.getSerializer())

// AndroidOptionsInitializer
- options.setEnvelopeDiskCache(new AndroidEnvelopeCache(options));
+ runtimeBuilder.envelopeDiskCache(new AndroidEnvelopeCache(options));

// SentryRuntime.Builder.build(options): the default moves here from Sentry.initConfigurations
+ envelopeDiskCache = cacheDirPath != null ? EnvelopeCache.create(options) : NoOpEnvelopeCache.getInstance();
  • The public SentryClient(options), AsyncHttpTransportFactory() and both AsyncHttpTransport constructors stay and read the cache off the options, as before.
  • A cache set through SentryOptions.setEnvelopeDiskCache still wins over the default, and getEnvelopeDiskCache() returns the runtime's cache.
  • InternalSentrySdk.updateSessionNonTerminating reads the cache from the current runtime.
  • PreviousSessionFinalizer also takes the serializer. It's the same constructor, and runtime.getSerializer() is lazy, so the JsonSerializer still isn't created on the init thread.

💡 Motivation and Context

Part of JAVA-817. Stacked on #6830.

💚 How did you test it?

The updated MovePreviousSessionTest, PreviousSessionFinalizerTest and AndroidOptionsInitializerTest.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Retarget to main once #6830 merges. This conflicts with the init-time executor PR on the initializeIntegrationsAndProcessors signature; whichever merges second rebases.

🤖 Generated with Claude Code

#skip-changelog

The SentryClient, its transport, and the previous-session tasks now get
the envelope disk cache through their constructors instead of reading it
off SentryOptions. The runtime creates the default cache, and Android
puts its AndroidEnvelopeCache on the runtime builder. The public
constructors that read the cache off the options keep working.

Part of JAVA-817

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@linear-code

linear-code Bot commented Dec 1, 2026

Copy link
Copy Markdown

JAVA-817

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

  • sentry-android-core/src/main/java/io/sentry/android/core/InternalSentrySdk.java
  • sentry/src/main/java/io/sentry/transport/AsyncHttpTransport.java

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 7452696.

Main concerns: reach, public contract, host performance.

Rules that block low also fired:

  • R4: a public API record changed: sentry/api/sentry.api

This label is a hint for reviewers, not an approval.

@sentry

sentry Bot commented Dec 1, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

This branch has not been deployed

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

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant