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 ConcurrentModificationException during unsubscription #1

Merged
merged 1 commit into from
Apr 16, 2019

Conversation

legolaswang
Copy link

fix java.util.ConcurrentModificationException on the subscriptions object, which may occur when dispatch an action while unsubscribe some StoreSubscribers

@@ -54,7 +54,7 @@ class Store<State: StateType> (
middleware(dispatch, getState)(dispatchFunction)
})

val subscriptions: MutableList<SubscriptionBox<State, Any>> = mutableListOf()
val subscriptions: java.util.concurrent.CopyOnWriteArrayList<SubscriptionBox<State, Any>> = CopyOnWriteArrayList()

Choose a reason for hiding this comment

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

you should probably use an import statement instead of the fully qualified name

Copy link
Author

Choose a reason for hiding this comment

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

sure

@NemoOudeis
Copy link

Does the CopyOnWriteArrayList solve the bug?

@NemoOudeis
Copy link

a note on the commit message: can follow our standard?, i.e.

in particular the header line and reference to the issue in the footer

Commit Messages

We write our commit messages according to the following pattern:

HEADER

BODY (optional)

FOOTER (optional)

with

  • HEADER = TYPE + DESC
    • TYPE = a short classifier of the type of commit, e.g. doc, feat, config, test
    • DESC = short description, <= 72 chars to display nicely on GitHub
  • BODY (optional) - can be multiple paragraths explaining the changes
  • FOOTER (optional) - references the JIRA ticket or GitHub issues this commit addresses

…when performing subscription/unsubscription

ConcurrentModificationException is thrown whenever the store is attempting to subscribe/unsubscribe any subscriber during dispatching new states.
This commit creates unit tests to reproduce this bug.
@NemoOudeis NemoOudeis merged commit 85e9ace into rakutentech:master Apr 16, 2019
NemoOudeis pushed a commit that referenced this pull request May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants