Skip to content

FIXED #1147 - [Scenario 4] Missing changes in Database Change Notific…#1166

Merged
pasin merged 4 commits intomasterfrom
feature/issue_1147_postChangeNotifications
Mar 28, 2016
Merged

FIXED #1147 - [Scenario 4] Missing changes in Database Change Notific…#1166
pasin merged 4 commits intomasterfrom
feature/issue_1147_postChangeNotifications

Conversation

@hideki
Copy link
Copy Markdown

@hideki hideki commented Mar 27, 2016

…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. I also all unit test with this fix with both genymotion and ARM API 19 emulator. And test passed.

…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();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need protected?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It should be private. Thank you.

@pasin pasin merged commit 79fc493 into master Mar 28, 2016
@pasin pasin deleted the feature/issue_1147_postChangeNotifications branch March 28, 2016 19:02
@pasin pasin removed the in progress label Mar 28, 2016
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.

2 participants