Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent ConcurrentModificationException when setting redactedKeys #947

Merged
merged 3 commits into from
Oct 7, 2020

Conversation

fractalwrench
Copy link
Contributor

@fractalwrench fractalwrench commented Oct 7, 2020

Goal

Prevents a ConcurrentModificationException from being thrown when redactedKeys is set on the Metadata of an Event. This can manifest as a crash when notify() is called concurrently.

Changeset

  • Converted ObjectJsonStreamer to use var Set<String> rather than val MutableSet<String>, as this avoids the problem of mutating a collection concurrently
  • Converted redactedKeys to a property on Metadata rather than a property and function, as this is more consistent
  • Removed ObjectJsonStreamer from the constructor as there is no need for it to be injectable

Testing

Added a unit test to verify that when redactedKeys is set on Metadata a crash does not occur. Additionally added an integration test which calls notify() concurrently to confirm that no further crashes occur with the default configuration.

@fractalwrench fractalwrench changed the title fix: prevent ConcurrentModificationException when setting redactedKeys Prevent ConcurrentModificationException when setting redactedKeys Oct 7, 2020
@fractalwrench fractalwrench force-pushed the PLAT-5175/redacted-key-exception branch from 515a8d4 to b2b35e6 Compare October 7, 2020 11:19
@fractalwrench fractalwrench marked this pull request as ready for review October 7, 2020 11:24
@bugsnagbot
Copy link
Collaborator

bugsnagbot commented Oct 7, 2020

Android notifier sizes

Format Size impact of Bugsnag (kB) Size impact of Bugsnag when Minified (kB)
APK 1437.59 1358.81
arm64_v8a 369.25 287.33
armeabi 348.77 266.85
armeabi_v7a 328.29 250.47
x86 406.1 324.19
x86_64 389.72 307.81

Generated by 🚫 Danger

Copy link
Contributor

@tomlongridge tomlongridge left a comment

Choose a reason for hiding this comment

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

LGTM - one request for an extra assertion.

@fractalwrench fractalwrench merged commit c3d240a into next Oct 7, 2020
@fractalwrench fractalwrench deleted the PLAT-5175/redacted-key-exception branch October 7, 2020 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants