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 Rx serialization bug in takeUntil again and the concurrent issue in BufferUntilSubscriber #1686

Merged
merged 3 commits into from
Oct 2, 2014

Conversation

zsxwing
Copy link
Member

@zsxwing zsxwing commented Sep 12, 2014

Sorry that #1656 is not a correct fix.

@zsxwing zsxwing changed the title Fix Rx serialization bug in takeUntil again Fix Rx serialization bug in takeUntil again and the concurrent issue in BufferUntilSubscriber Sep 13, 2014
@zsxwing
Copy link
Member Author

zsxwing commented Sep 13, 2014

Also fixed BufferUntilSubscriber as per #1677

onError should be ignored after unsubscribe is called.
@akarnokd
Copy link
Member

I thought about this but couldn't find any reason the original had race if the caller to onXXX is serialized proprly, as you mentioned in #1677.

@zsxwing
Copy link
Member Author

zsxwing commented Sep 15, 2014

In the original codes, https://github.com/zsxwing/RxJava/blob/af4fc88b3321247c6e6e2778ae6f3226c742dac0/rxjava-core/src/main/java/rx/internal/operators/BufferUntilSubscriber.java#L101, L101-L105 is not atomic. It means between L101(checking if the buffer is empty) and L105(setting PassThruObserver), other threads may add new items into the buffer. Assume that after L105(setting PassThruObserver), no further message will come. Therefore, drainIfNeededAndSwitchToActual won't be called, and the items in the buffer won't be taken.

@zsxwing
Copy link
Member Author

zsxwing commented Sep 15, 2014

I thought about this but couldn't find any reason the original had race if the caller to onXXX is serialized proprly, as you mentioned in #1677.

Sorry that my comments in #1677 about PublishSubject confused you. It's irrelevant to this PR.

@akarnokd
Copy link
Member

Thanks, that makes sense.

@benjchristensen
Copy link
Member

Yeesh that was painful. Thanks both of you.

benjchristensen added a commit that referenced this pull request Oct 2, 2014
Fix Rx serialization bug in takeUntil again and the concurrent issue in BufferUntilSubscriber
@benjchristensen benjchristensen merged commit 56778fd into ReactiveX:0.20.x Oct 2, 2014
@zsxwing zsxwing deleted the fix-takeUntil branch October 3, 2014 14:20
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.

3 participants