Skip to content
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 destroying lock instance #1653

Merged
merged 2 commits into from
May 23, 2019
Merged

Fix destroying lock instance #1653

merged 2 commits into from
May 23, 2019

Conversation

luisrudge
Copy link
Contributor

@luisrudge luisrudge commented May 22, 2019

fix #907, #1090, #1091

Changes

This is a copy of #1091, but I couldn't rebase because the original branch was removed.

This fixes a case where lock couldn't be destroyed lock.destroy().

@luisrudge luisrudge requested a review from a team May 22, 2019 14:19
@@ -7,7 +7,9 @@ export function observe(key, id, f) {
subscribe(`${key}-${id}`, (_, oldState, newState) => {
const m = getEntity(newState, 'lock', id);
const oldM = getEntity(oldState, 'lock', id);
if (m != oldM) f(m);
if (m && !m.equals(oldM)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps (m != null) would be safer? What types does getEntity return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they will always be different because m is an immutable object (which is a new reference, so will always be false if you compare with !=). that's why the fix is actually use .equals, which is an immutable method.

@luisrudge luisrudge merged commit 321fa77 into master May 23, 2019
@luisrudge luisrudge deleted the fix/destroy branch May 23, 2019 02:50
@luisrudge luisrudge added this to the v11.16.1 milestone Jun 3, 2019
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.

Unable to destroy Lock instance
2 participants