From 081d19498645ab8fc2d074e02ea6edbee2a71280 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 9 Apr 2024 17:58:56 +0100 Subject: [PATCH] fix(json): make the default ObjectJsonStreamer.redactedKeys a static shared value (it's immutable) --- CHANGELOG.md | 2 ++ .../src/main/java/com/bugsnag/android/ObjectJsonStreamer.kt | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a71f93267c..62fd3e1c08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ * FeatureFlags are now a copy-on-write structure, and so don't need to be defensive copied on a crashing thread [#2005](https://github.com/bugsnag/bugsnag-android/pull/2005) +* The default redactedKeys in ObjectJsonStreamer is now static and shared, reducing the overhead of some leaveBreadcrumb calls (those with complex metadata) + []() * Allow `Bugsnag.startSession` to be called with automatic session tracking, and not have the first manual session be over written by the first automatic session. [#2006](https://github.com/bugsnag/bugsnag-android/pull/2006) diff --git a/bugsnag-android-core/src/main/java/com/bugsnag/android/ObjectJsonStreamer.kt b/bugsnag-android-core/src/main/java/com/bugsnag/android/ObjectJsonStreamer.kt index 5df61b8ae9..abcb927c77 100644 --- a/bugsnag-android-core/src/main/java/com/bugsnag/android/ObjectJsonStreamer.kt +++ b/bugsnag-android-core/src/main/java/com/bugsnag/android/ObjectJsonStreamer.kt @@ -11,9 +11,11 @@ internal class ObjectJsonStreamer { companion object { internal const val REDACTED_PLACEHOLDER = "[REDACTED]" internal const val OBJECT_PLACEHOLDER = "[OBJECT]" + + internal val DEFAULT_REDACTED_KEYS = setOf(Pattern.compile(".*password.*", Pattern.CASE_INSENSITIVE)) } - var redactedKeys = setOf(Pattern.compile(".*password.*", Pattern.CASE_INSENSITIVE)) + var redactedKeys = DEFAULT_REDACTED_KEYS // Write complex/nested values to a JsonStreamer @Throws(IOException::class)