customerio / customerio-android

This is the official Customer.io SDK for Android.
MIT License
11 stars 9 forks source link

fix: prevent concurrency issues in in-app listeners #246

Closed mrehan27 closed 10 months ago

mrehan27 commented 11 months ago

fixes: https://github.com/customerio/customerio-android/issues/245

Changes

github-actions[bot] commented 11 months ago
# Sample app builds 📱 Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request. --- * java_layout: `fix/in-app-listeners-concurrent-modification-crash (1692776802)` * kotlin_compose: `fix/in-app-listeners-concurrent-modification-crash (1692776802)`
github-actions[bot] commented 11 months ago

Pull request title looks good 👍!

If this pull request gets merged, it will cause a new release of the software. Example: If this project's latest release version is 1.0.0. If this pull request gets merged in, the next release of this project will be 1.0.1. This pull request is not a breaking change.

All merged pull requests will eventually get deployed. But some types of pull requests will trigger a deployment (such as features and bug fixes) while some pull requests will wait to get deployed until a later time.

This project uses a special format for pull requests titles. Expand this section to learn more (expand by clicking the ᐅ symbol on the left side of this sentence)...
This project uses a special format for pull requests titles. Don't worry, it's easy! This pull request title should be in this format: ``` : short description of change being made ``` **If your pull request [introduces breaking changes](https://web.archive.org/web/20220725195319/https://nordicapis.com/what-are-breaking-changes-and-how-do-you-avoid-them/)** to the code, use this format: ``` !: short description of breaking change ``` where `` is one of the following: - `feat:` - A feature is being added or modified by this pull request. Use this if you made any changes to any of the features of the project. - `fix:` - A bug is being fixed by this pull request. Use this if you made any fixes to bugs in the project. - `docs:` - This pull request is making documentation changes, only. - `refactor:` - A change was made that doesn't fix a bug or add a feature. - `test:` - Adds missing tests or fixes broken tests. - `style:` - Changes that do not effect the code (whitespace, linting, formatting, semi-colons, etc) - `perf:` - Changes improve performance of the code. - `build:` - Changes to the build system (maven, npm, gulp, etc) - `ci:` - Changes to the CI build system (Travis, GitHub Actions, Circle, etc) - `chore:` - Other changes to project that don't modify source code or test files. - `revert:` - Reverts a previous commit that was made. ### Examples: ``` feat: edit profile photo refactor!: remove deprecated v1 endpoints build: update npm dependencies style: run formatter ``` Need more examples? Want to learn more about this format? [Check out the official docs](https://www.conventionalcommits.org/). **Note:** If your pull request does multiple things such as adding a feature _and_ makes changes to the CI server _and_ fixes some bugs then you might want to consider splitting this pull request up into multiple smaller pull requests.
codecov[bot] commented 11 months ago

Codecov Report

Merging #246 (19fce99) into main (0587efa) will increase coverage by 1.04%. The diff coverage is 100.00%.

@@             Coverage Diff              @@
##               main     #246      +/-   ##
============================================
+ Coverage     49.76%   50.80%   +1.04%     
- Complexity      237      249      +12     
============================================
  Files           108      108              
  Lines          2781     2781              
  Branches        364      364              
============================================
+ Hits           1384     1413      +29     
+ Misses         1282     1250      -32     
- Partials        115      118       +3     
Files Changed Coverage Δ
...stomer/messaginginapp/gist/presentation/GistSdk.kt 13.38% <100.00%> (+13.38%) :arrow_up:

... and 2 files with indirect coverage changes

github-actions[bot] commented 11 months ago

Build available to test Version: fix-in-app-listeners-concurrent-modification-crash-SNAPSHOT Repository: https://s01.oss.sonatype.org/content/repositories/snapshots/

mrehan27 commented 11 months ago

I tried different approaches and Shahroz's suggestion for trying thread safe collections looked the best option. I have used CopyOnWriteArrayList which works well and added tests. The tests passes with current implementation and fail if we run them on previous implementation.