File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99@ ApiStatus .Internal
1010public final class DataCollectionResolver {
1111
12- private static final @ NotNull KeyValueCollectionBehavior OFF = KeyValueCollectionBehavior .off ();
13- private static final @ NotNull KeyValueCollectionBehavior EMPTY_DENY_LIST =
14- KeyValueCollectionBehavior .denyList ();
15-
1612 private final @ NotNull SentryOptions options ;
1713
1814 DataCollectionResolver (final @ NotNull SentryOptions options ) {
@@ -67,9 +63,11 @@ public boolean isGraphqlVariablesWithLegacyAlways() {
6763 return cookies ;
6864 }
6965 if (isDataCollectionConfigured ()) {
70- return EMPTY_DENY_LIST ;
66+ return KeyValueCollectionBehavior . denyList () ;
7167 }
72- return options .isSendDefaultPii () ? EMPTY_DENY_LIST : OFF ;
68+ return options .isSendDefaultPii ()
69+ ? KeyValueCollectionBehavior .denyList ()
70+ : KeyValueCollectionBehavior .off ();
7371 }
7472
7573 public @ NotNull KeyValueCollectionBehavior getUrlQueryParams () {
@@ -124,7 +122,7 @@ private boolean explicitOrDefault(
124122
125123 private @ NotNull KeyValueCollectionBehavior explicitOrEmptyDenyList (
126124 final @ Nullable KeyValueCollectionBehavior explicit ) {
127- return explicit != null ? explicit : EMPTY_DENY_LIST ;
125+ return explicit != null ? explicit : KeyValueCollectionBehavior . denyList () ;
128126 }
129127
130128 private boolean isHttpBodyEnabled (
Original file line number Diff line number Diff line change @@ -233,6 +233,17 @@ class DataCollectionResolverTest {
233233 assertThat(options.dataCollectionResolver.cookies).isEqualTo(KeyValueCollectionBehavior .off())
234234 }
235235
236+ @Test
237+ fun `mutating one fallback key-value behavior does not affect other getters` () {
238+ val resolver = SentryOptions ().apply { dataCollection.setUserInfo(true ) }.dataCollectionResolver
239+
240+ resolver.cookies.terms = listOf (" custom-cookie" )
241+
242+ assertThat(resolver.urlQueryParams.terms).doesNotContain(" custom-cookie" )
243+ assertThat(resolver.httpRequestHeaders.terms).doesNotContain(" custom-cookie" )
244+ assertThat(resolver.httpResponseHeaders.terms).doesNotContain(" custom-cookie" )
245+ }
246+
236247 @Test
237248 fun `cookies use default deny list when unset and sendDefaultPii is true` () {
238249 val options = SentryOptions ().apply { isSendDefaultPii = true }
You can’t perform that action at this time.
0 commit comments