You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7c1a728
Browse filesBrowse the repository at this point in the historyBrowse files
chore(android-sqlite): Skip wrapping SupportSQLiteDriver bridge to avoid duplicate spans (#5514)
SentrySQLiteDriver.create() now recognizes the Room 2.7+ androidx.sqlite.driver.SupportSQLiteDriver bridge adapter and returns it unwrapped. That lets us protect against the one known vector where using both SentrySQLiteDriver and SentrySupportSQLiteOpenHelper with the same db table is allowed under either the Room or SQLDelight APIs:
```kotlin
// AVOID — this configuration produces duplicate spans for every SQL statement.
// Step 1: Developer wraps their open helper with Sentry, either manually or
// via the Sentry Android Gradle Plugin.
val sentryWrappedHelper: SupportSQLiteOpenHelper =
SentrySupportSQLiteOpenHelper.create(
FrameworkSQLiteOpenHelperFactory().create(configuration)
)
// Step 2: Developer builds the compat driver around that wrapped helper.
val driver: SQLiteDriver = SupportSQLiteDriver(sentryWrappedHelper)
// Step 3: Developer (wrongly!) wraps the driver with Sentry as well. All
// spans will now be duplicated.
val sentryWrappedDriver: SQLiteDriver = SentrySQLiteDriver.create(driver)
Room.databaseBuilder(context, MyDb::class.java, "mydb")
.setDriver(sentryWrappedDriver)
.build()
```
This commit lets us avoid step 3 by no-op'ing if a developer tries to pass a SupportSQLiteDriver to SentrySQLiteDriver.create().
0 commit comments