Skip to content

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

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

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

Conversation

@runningcode

@runningcode runningcode commented Dec 1, 2026 •

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, services.cache) ─► AsyncHttpTransportFactory(cache) ─► AsyncHttpTransport(…, cache)
- new MovePreviousSession(options)
+ new MovePreviousSession(options, services.getEnvelopeDiskCache())
- new PreviousSessionFinalizer(options, scopes)
+ new PreviousSessionFinalizer(options, scopes, services.getEnvelopeDiskCache(), services.getSerializer())

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

// InternalServices.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 same cache.
  • InternalSentrySdk.updateSessionNonTerminating reads the cache from the current InternalServices.
  • PreviousSessionFinalizer also takes the serializer. It's the same constructor, and services.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

@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 3f5b40f.

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.67.0 (1) release

⚙️ sentry-android Build Distribution Settings

@runningcode
runningcode force-pushed the no/sentryruntime-foundation branch from 4b9b580 to a993645 Compare December 3, 2026 12:24
@runningcode
runningcode force-pushed the no/sentryruntime-disk-cache branch from 7452696 to 9aa5ba8 Compare December 3, 2026 12:24
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 3, 2026
@runningcode
runningcode force-pushed the no/sentryruntime-disk-cache branch from 9aa5ba8 to cd30aef Compare December 3, 2026 12:52
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 3, 2026
@runningcode
runningcode force-pushed the no/sentryruntime-disk-cache branch from cd30aef to 5f4dad6 Compare December 3, 2026 14:52
@runningcode runningcode changed the title ref(core): Inject the envelope disk cache from SentryRuntime ref(core): Inject the envelope disk cache from InternalServices Dec 3, 2026
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 3, 2026
The SentryClient, its transport, and the previous-session tasks now get
the envelope disk cache through their constructors instead of reading it
off SentryOptions. InternalServices creates the default cache, and Android
puts its AndroidEnvelopeCache on the InternalServices builder. The public
constructors that read the cache off the options keep working.

Part of JAVA-817

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/sentryruntime-disk-cache branch from 5f4dad6 to 3f5b40f Compare December 3, 2026 15:03
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 3, 2026
@runningcode
runningcode marked this pull request as ready for review December 3, 2026 15:27
@runningcode
runningcode requested review from a team and adinauer as code owners December 3, 2026 15:27
@runningcode
runningcode requested review from 0xadam-brown and romtsn and removed request for a team December 3, 2026 15:27
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 3, 2026

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