22
33import io .sentry .protocol .SdkVersion ;
44import io .sentry .util .SampleRateUtils ;
5-
65import java .util .Arrays ;
6+ import java .util .Collections ;
77import java .util .LinkedHashSet ;
88import java .util .List ;
99import java .util .Locale ;
@@ -181,30 +181,30 @@ public enum SentryReplayQuality {
181181 private boolean networkCaptureBodies = true ;
182182
183183 /** Default headers that are always captured for URLs defined in networkDetailAllowUrls. */
184- private static final @ NotNull String [] DEFAULT_HEADERS =
185- new String [] { "Content-Type" , "Content-Length" , "Accept" } ;
184+ private static final @ NotNull List < String > DEFAULT_HEADERS =
185+ Collections . unmodifiableList ( Arrays . asList ( "Content-Type" , "Content-Length" , "Accept" )) ;
186186
187187 /**
188188 * Gets the default headers that are always captured for URLs defined in networkDetailAllowUrls.
189- * Returns a defensive copy to prevent modification.
189+ *
190+ * @return an unmodifiable list
190191 */
191192 @ ApiStatus .Internal
192- public static @ NotNull String [] getNetworkDetailsDefaultHeaders () {
193- return DEFAULT_HEADERS . clone () ;
193+ public static @ NotNull List < String > getNetworkDetailsDefaultHeaders () {
194+ return DEFAULT_HEADERS ;
194195 }
195196
196197 /**
197198 * Additional request headers to capture for URLs defined in networkDetailAllowUrls. The default
198199 * headers (Content-Type, Content-Length, Accept) are always included in addition to these.
199200 */
200- private @ NotNull String [] networkRequestHeaders = DEFAULT_HEADERS .clone ( );
201+ private @ NotNull String [] networkRequestHeaders = DEFAULT_HEADERS .toArray ( new String [ 0 ] );
201202
202203 /**
203204 * Additional response headers to capture for URLs defined in networkDetailAllowUrls. The default
204205 * headers (Content-Type, Content-Length, Accept) are always included in addition to these.
205206 */
206- private @ NotNull String [] networkResponseHeaders = DEFAULT_HEADERS .clone ();
207-
207+ private @ NotNull String [] networkResponseHeaders = DEFAULT_HEADERS .toArray (new String [0 ]);
208208
209209 public SentryReplayOptions (final boolean empty , final @ Nullable SdkVersion sdkVersion ) {
210210 if (!empty ) {
@@ -493,8 +493,8 @@ public void setNetworkCaptureBodies(final boolean networkCaptureBodies) {
493493 }
494494
495495 /**
496- * Sets request headers to capture for URLs defined in networkDetailAllowUrls. The
497- * default headers (Content-Type, Content-Length, Accept) are always included automatically.
496+ * Sets request headers to capture for URLs defined in networkDetailAllowUrls. The default headers
497+ * (Content-Type, Content-Length, Accept) are always included automatically.
498498 *
499499 * @param networkRequestHeaders additional network request headers list
500500 */
@@ -513,8 +513,8 @@ public void setNetworkRequestHeaders(final @NotNull List<String> networkRequestH
513513 }
514514
515515 /**
516- * Sets response headers to capture for URLs defined in networkDetailAllowUrls. The
517- * default headers (Content-Type, Content-Length, Accept) are always included automatically.
516+ * Sets response headers to capture for URLs defined in networkDetailAllowUrls. The default
517+ * headers (Content-Type, Content-Length, Accept) are always included automatically.
518518 *
519519 * @param networkResponseHeaders the additional network response headers list
520520 */
@@ -529,9 +529,9 @@ public void setNetworkResponseHeaders(final @NotNull List<String> networkRespons
529529 * @param additionalHeaders additional headers to merge
530530 */
531531 private static @ NotNull String [] mergeHeaders (
532- final @ NotNull String [] defaultHeaders , final @ NotNull List <String > additionalHeaders ) {
532+ final @ NotNull List < String > defaultHeaders , final @ NotNull List <String > additionalHeaders ) {
533533 final Set <String > merged = new LinkedHashSet <>();
534- merged .addAll (Arrays . asList ( defaultHeaders ) );
534+ merged .addAll (defaultHeaders );
535535 merged .addAll (additionalHeaders );
536536 return merged .toArray (new String [0 ]);
537537 }
0 commit comments