Skip to content

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

Merged
merged 5 commits into from
Jul 25, 2023
Merged

Fix push store crash #952

merged 5 commits into from
Jul 25, 2023

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Jul 24, 2023

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.

@bmarty bmarty requested a review from a team as a code owner July 24, 2023 13:29
@bmarty bmarty requested review from ganfra and removed request for a team July 24, 2023 13:29
context = context,
userId = userId
)
return synchronized(cache) {
Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

Use a ConcurrentHashMap?

Copy link
Member Author

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.

@github-actions
Copy link
Contributor

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link:

@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.01% ⚠️

Comparison is base (e6d27ac) 56.75% compared to head (a6c96af) 56.74%.

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              
Files Changed Coverage Δ
...ries/pushstore/impl/DefaultUserPushStoreFactory.kt 0.00% <0.00%> (ø)
...essionstorage/test/observer/NoOpSessionObserver.kt 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@bmarty bmarty merged commit caaa192 into develop Jul 25, 2023
@bmarty bmarty deleted the feature/bma/fixPushStoreCrash branch July 25, 2023 07:43
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.

[Crash] push datastore usage
2 participants