-
Notifications
You must be signed in to change notification settings - Fork 232
Fix push store crash #952
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
Fix push store crash #952
Conversation
context = context, | ||
userId = userId | ||
) | ||
return synchronized(cache) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is the fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a ConcurrentHashMap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc of ConcurrentMap<K, V>.getOrPut
:
Concurrent getOrPut, that is safe for concurrent maps.
Returns the value for the given key. If the key is not found in the map, calls the defaultValue function, puts its result into the map under the given key and returns it.
This method guarantees not to put the value into the map if the key is already there, but the defaultValue function may be invoked even if the key is already in the map.
I was a bit scared by the last sentence, but actually this is fine. At worse a UserPushStoreDataStore
is built and thrown away.
I have change it and the test is still passing.
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## develop #952 +/- ##
===========================================
- Coverage 56.75% 56.74% -0.01%
===========================================
Files 973 974 +1
Lines 24677 24680 +3
Branches 5009 5009
===========================================
Hits 14005 14005
- Misses 8455 8458 +3
Partials 2217 2217
☔ View full report in Codecov by Sentry. |
Kudos, SonarCloud Quality Gate passed!
|
Fixes #950.
First commit remove unused gradle dep.
I added a connected test, which has to be run manually (the CI does not run connectedAndroidTest right now).
The test was failing before the fix and is passing now.