diff --git a/CHANGELOG.md b/CHANGELOG.md index b6a6b69527..11b236df97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/sentry/src/main/java/io/sentry/util/CookieUtils.java b/sentry/src/main/java/io/sentry/util/CookieUtils.java index e50633a298..2af64b009c 100644 --- a/sentry/src/main/java/io/sentry/util/CookieUtils.java +++ b/sentry/src/main/java/io/sentry/util/CookieUtils.java @@ -55,7 +55,7 @@ public final class CookieUtils { filteredHeaders.add(filteredHeader); } } - return filteredHeaders; + return filteredHeaders.isEmpty() ? null : filteredHeaders; } public static @Nullable String filterCookies( diff --git a/sentry/src/test/java/io/sentry/util/CookieUtilsTest.kt b/sentry/src/test/java/io/sentry/util/CookieUtilsTest.kt index 183dec4a12..96bec1a4f4 100644 --- a/sentry/src/test/java/io/sentry/util/CookieUtilsTest.kt +++ b/sentry/src/test/java/io/sentry/util/CookieUtilsTest.kt @@ -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(