Skip to content
Draft
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Fixes

- Keep dropped tombstone and ANR events dropped, instead of reporting the same app exit again at every app start ([#6002](https://github.com/getsentry/sentry-java/pull/6002))
- Clear the persisted replay id on SDK init, so a replay id from a previous process is no longer attached to ANR events from the current one ([#6033](https://github.com/getsentry/sentry-java/pull/6033))
- Apply `Sentry.withScope` and `Sentry.withIsolationScope` data to events captured inside the callback when `globalHubMode` is enabled ([#6004](https://github.com/getsentry/sentry-java/pull/6004))
- `globalHubMode` is enabled by default on Android, where tags, extras, contexts and level set inside the callback were silently dropped
- Scopes that are explicitly made current, e.g. via `Sentry.setCurrentScopes` or the `SentryContext` coroutine integration, are now also honoured when `globalHubMode` is enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,5 +378,8 @@ public void resetCache() {
delete(TAGS_FILENAME);
delete(TRACE_FILENAME);
delete(TRANSACTION_FILENAME);
// the replay this id points at belongs to the previous process, so it must not be attached to
// events from this one; the replay integration writes a fresh id once it starts recording
delete(REPLAY_FILENAME);
Comment on lines +381 to +383

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd remove the comments here, as clearing the replay id is not any different than the items above

Suggested change
// the replay this id points at belongs to the previous process, so it must not be attached to
// events from this one; the replay integration writes a fresh id once it starts recording
delete(REPLAY_FILENAME);
delete(REPLAY_FILENAME);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import io.sentry.ISentryExecutorService
import io.sentry.ISerializer
import io.sentry.SentryOptions
import io.sentry.cache.PersistingScopeObserver.BREADCRUMBS_FILENAME
import io.sentry.cache.PersistingScopeObserver.REPLAY_FILENAME
import io.sentry.cache.PersistingScopeObserver.TRANSACTION_FILENAME
import io.sentry.protocol.SentryId
import io.sentry.test.DeferredExecutorService
import java.io.Writer
import java.util.concurrent.atomic.AtomicBoolean
Expand All @@ -28,6 +30,9 @@ class PersistingScopeObserverBatchingTest {
private fun PersistingScopeObserver.readTransaction(): String? =
read(options, TRANSACTION_FILENAME, String::class.java)

private fun PersistingScopeObserver.readReplayId(): String? =
read(options, REPLAY_FILENAME, String::class.java)

@Suppress("UNCHECKED_CAST")
private fun PersistingScopeObserver.readBreadcrumbs(): List<Breadcrumb> =
read(options, BREADCRUMBS_FILENAME, List::class.java) as List<Breadcrumb>
Expand Down Expand Up @@ -118,6 +123,20 @@ class PersistingScopeObserverBatchingTest {
}
}

@Test
fun `resetCache clears the replay id left behind by the previous process`() {
val executor = DeferredExecutorService()
val sut = getSut(executor)

sut.setReplayId(SentryId("afcb46b1140ade5187c4bbb5daa804df"))
executor.runAll()
assertThat(sut.readReplayId()).isEqualTo("afcb46b1140ade5187c4bbb5daa804df")

sut.resetCache()

assertThat(sut.readReplayId()).isNull()
}

@Test
fun `resetCache keeps pending mutations from the current process`() {
val executor = DeferredExecutorService()
Expand Down
Loading