Skip to content
Open
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 @@ -140,6 +140,7 @@

### Fixes

- Omit request cookies when no cookie headers are present ([#6799](https://github.com/getsentry/sentry-java/pull/6799))
- Set Apollo 3, 4, and 5 HTTP spans to `CANCELLED` instead of `INTERNAL_ERROR` when the request is cancelled ([#6284](https://github.com/getsentry/sentry-java/pull/6284))
- Preserve independent Netty read and write timeout events when exception singletons are reused. These exceptions now bypass event deduplication by default, so applications with multiple capture integrations may report the same timeout more than once. Use `SentryOptions.setIgnoredErrorsForDeduplication(...)` or `ignored-errors-for-deduplication` to customize or clear the default exclusions. ([#6465](https://github.com/getsentry/sentry-java/pull/6465))
- Prevent changes to reused tracing options from affecting spans and transactions after creation ([#6417](https://github.com/getsentry/sentry-java/pull/6417))
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/util/CookieUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public final class CookieUtils {
filteredHeaders.add(filteredHeader);
}
}
return filteredHeaders;
return filteredHeaders.isEmpty() ? null : filteredHeaders;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

theoretically we could assign it to null and only initialize an ArrayList inside the for-loop in the first iteration. This would avoid unnecessary allocation and simplify this to just return filteredHeaders, but that's a micro-optimization so up to you :)

}

public static @Nullable String filterCookies(
Expand Down
24 changes: 24 additions & 0 deletions sentry/src/test/java/io/sentry/util/CookieUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,30 @@ class CookieUtilsTest {
.isNull()
}

@Test
fun `empty cookie header list returns null`() {
assertThat(
CookieUtils.filterCookiesFromHeader(
emptyList(),
KeyValueCollectionBehavior.denyList(),
emptyList(),
),
)
.isNull()
}

@Test
fun `empty cookie header enumeration returns null`() {
assertThat(
CookieUtils.filterCookiesFromHeader(
java.util.Collections.enumeration(emptyList()),
KeyValueCollectionBehavior.denyList(),
emptyList(),
),
)
.isNull()
}

@Test
fun `cookie header filter processes every header value`() {
assertThat(
Expand Down
Loading