FIXED #1147 - [Scenario 4] Missing changes in Database Change Notific…#1166
Merged
FIXED #1147 - [Scenario 4] Missing changes in Database Change Notific…#1166
Conversation
…ation As @pasin analyzed, `changesToNotify`, `postingChangeNotifications`, `changeListeners`, and `databaseListeners` variables are not thread-safe. In this scenario, `changeListener` and `databaseListners` are not added/removed in concurrent env. These two variables don't directly cause the problem with under unit-test scenario. `changesToNotify` and `postingChangeNotifications` makes test fails. Especially, `changesToNotify` variable. By this commit, make all four variables thread-safe. And make `postChangeNotifications()` method thread-safe by `postingChangeNotifications` variable and `lockPostingChangeNotifications` lock object. I run `testDatabaseChangeNotification()` unit test with this fix many times with Genymotion emulator (faster test env) and Stock Emulator ARM API 19 (slower test env). With this fix, the test never failed again.
| private List<DocumentChange> changesToNotify; | ||
| final private List<DocumentChange> changesToNotify; | ||
| private boolean postingChangeNotifications; | ||
| final protected Object lockPostingChangeNotifications = new Object(); |
Author
There was a problem hiding this comment.
It should be private. Thank you.
added 3 commits
March 28, 2016 09:47
…`private` based on [ the code review feedback](#1166 (comment))
Also changed `open` variable to `AtomicBoolean` from `boolean`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ation
As @pasin analyzed,
changesToNotify,postingChangeNotifications,changeListeners, anddatabaseListenersvariables are not thread-safe. In this scenario,changeListeneranddatabaseListnersare not added/removed in concurrent env. These two variables don't directly cause the problem with under unit-test scenario.changesToNotifyandpostingChangeNotificationsmakes test fails. Especially,changesToNotifyvariable. By this commit, make all four variables thread-safe. And makepostChangeNotifications()method thread-safe bypostingChangeNotificationsvariable andlockPostingChangeNotificationslock object.I run
testDatabaseChangeNotification()unit test with this fix many times with Genymotion emulator (faster test env) and Stock Emulator ARM API 19 (slower test env). With this fix, the test never failed again. I also all unit test with this fix with both genymotion and ARM API 19 emulator. And test passed.