Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Ensure android initialization process continues even if options configuration block throws an exception ([#3887](https://github.com/getsentry/sentry-java/pull/3887))

## 7.17.0

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,17 @@ public static synchronized void init(
isTimberAvailable,
isReplayAvailable);

configuration.configure(options);
try {
configuration.configure(options);
} catch (Throwable t) {
// let it slip, but log it
options
.getLogger()
.log(
SentryLevel.ERROR,
"Error in the 'OptionsConfiguration.configure' callback.",
t);
}

// if SentryPerformanceProvider was disabled or removed,
// we set the app start / sdk init time here instead
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,19 @@ class SentryAndroidTest {
assertEquals(99, AppStartMetrics.getInstance().appStartTimeSpan.startUptimeMs)
}

@Test
fun `if the config options block throws still intializes android event processors`() {
lateinit var optionsRef: SentryOptions
fixture.initSut(context = mock<Application>()) { options ->
optionsRef = options
options.dsn = "https://[email protected]/123"
throw RuntimeException("Boom!")
}

assertTrue(optionsRef.eventProcessors.any { it is DefaultAndroidEventProcessor })
assertTrue(optionsRef.eventProcessors.any { it is AnrV2EventProcessor })
}

private fun prefillScopeCache(cacheDir: String) {
val scopeDir = File(cacheDir, SCOPE_CACHE).also { it.mkdirs() }
File(scopeDir, BREADCRUMBS_FILENAME).writeText(
Expand Down
Loading