-
Notifications
You must be signed in to change notification settings - Fork 17
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
[MOB-21074] Fix threading issues during map updates in updateProposition #87
Conversation
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.
Could you please fix the lint errors?
30698ca
to
c1b51d2
Compare
…ionsInProgress hashmaps to static and final hashmaps
code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/OptimizeExtension.java
Outdated
Show resolved
Hide resolved
code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/OptimizeExtension.java
Outdated
Show resolved
Hide resolved
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.
Pending approval from Praveen
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.
Looking at this a bit more, I still don't think it is thread-safe. cachedPropositions
is read from a different thread than the Optimize extension one, inside the SerialWorkDispatcher
. We might also need to use ConcurrentHashMap for that. Thoughts?
…ConcurrentHashMap for update and get Propostions
code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/OptimizeExtension.java
Outdated
Show resolved
Hide resolved
code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/OptimizeExtension.java
Outdated
Show resolved
Hide resolved
code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/OptimizeExtension.java
Outdated
Show resolved
Hide resolved
code/optimize/src/test/java/com/adobe/marketing/mobile/optimize/OptimizeExtensionTests.java
Outdated
Show resolved
Hide resolved
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.
Similar changes are also needed for cachedPropositions
as it is also accessed from multiple threads.
…ucture of cachedPropositions to ConcurrentHashMap from hashmap
code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/OptimizeExtension.java
Outdated
Show resolved
Hide resolved
code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/OptimizeExtension.java
Outdated
Show resolved
Hide resolved
code/optimize/src/main/java/com/adobe/marketing/mobile/optimize/OptimizeExtension.java
Outdated
Show resolved
Hide resolved
…ization and updating the comments accordingly
Description
Changing the hash map to concurrent hash map in order to ensure the thread safety and avoid the race condition
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: