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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

### Fixes

- Fix attachments being duplicated on native events that carry scope attachments ([#5548](https://github.com/getsentry/sentry-java/pull/5548))
- Fix performance collector scheduling many tasks in a row ([#5524](https://github.com/getsentry/sentry-java/pull/5524))

## 8.43.2
Expand Down
4 changes: 3 additions & 1 deletion sentry/src/main/java/io/sentry/SentryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ private boolean shouldApplyScopeData(final @NotNull CheckIn event, final @NotNul
hint = new Hint();
}

if (shouldApplyScopeData(event, hint)) {
// Cached envelopes (e.g. native crashes from the outbox) already carry their attachments as
// envelope items. Re-applying scope attachments here would duplicate them.
if (shouldApplyScopeData(event, hint) && !HintUtils.hasType(hint, Cached.class)) {
addScopeAttachmentsToHint(scope, hint);
}

Expand Down
19 changes: 19 additions & 0 deletions sentry/src/test/java/io/sentry/SentryClientTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,25 @@ class SentryClientTest {
assertEquals(scope.level, event.level)
}

@Test
fun `when hint is Cached, scope attachments are not added to avoid duplication`() {
val sut = fixture.getSut()

val event = createEvent()
val scope = createScopeWithAttachments()

val hints = HintUtils.createWithTypeCheckHint(CustomCachedApplyScopeDataHint())
sut.captureEvent(event, scope, hints)

verify(fixture.transport)
.send(
check { actual ->
assertEquals(0, actual.items.count { it.header.type == SentryItemType.Attachment })
},
anyOrNull(),
)
}

@Test
fun `when transport factory is NoOp, it should initialize it`() {
fixture.sentryOptions.setTransportFactory(NoOpTransportFactory.getInstance())
Expand Down
Loading