-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fixed concurrent modifications in UI components when subscribing taken events #162
Conversation
@@ -75,7 +75,7 @@ public boolean removeOnClickListener(final View.OnClickListener listener) { | |||
|
|||
@Override | |||
public void onClick(final View view) { | |||
for (final View.OnClickListener listener : listeners) { | |||
for (final View.OnClickListener listener: new ArrayList<View.OnClickListener>(listeners)) { |
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.
This is extremely wasteful. Try a CopyOnWriteArrayList
for listeners
instead?
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.
Thanks for the reasonable comment.
I modified the codes to match it, and pushed them.
Did you find out when/how the list of listeners is being modified from a background thread? |
I did. In this case, a taken (and completed) observer will try to unsubscribe events on UiThread after invoking onNext(View). So the solution is using CopyOnWriteArrayList or to create new list, I think. |
@@ -75,7 +76,7 @@ public boolean removeOnClickListener(final View.OnClickListener listener) { | |||
|
|||
@Override | |||
public void onClick(final View view) { | |||
for (final View.OnClickListener listener : listeners) { | |||
for (final View.OnClickListener listener: listeners) { |
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.
Can you revert all of these small whitespace changes, unnecessary usages of final
?
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.
@ronshapiro I see. Minimized diffs.
+1 |
This is fixed in https://github.com/JakeWharton/RxBinding but per #172 this won't be going into RxAndroid core. We have removed the view binding observables for the next release. |
This fixes ConcurrentModificationException which is thrown by Observables that invoked Observable#take(int).
Relevant issue is #158 .