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 race condition in SpliceFlatStreamToMetaSingle #1845

Merged
merged 1 commit into from
Sep 29, 2021

Conversation

Scottmitch
Copy link
Member

Motivation:
SpliceFlatStreamToMetaSingle has a race condition which may result in
concurrency invocation of a Subscriber which is prohibited by the
Reactive Streams specification [1].

[1] https://github.com/reactive-streams/reactive-streams-jvm/blob/v1.0.3/README.md#1.3

Modifications:

  • Use a DelayedSubscription so onSubscribe is invoked before the
    Subscriber reference is made visible to other threads which may
    invoke terminal methods on the Subscriber.

Result:
SpliceFlatStreamToMetaSingle is more compliant with RS spec and provides
more predictable behavior.

Motivation:
SpliceFlatStreamToMetaSingle has a race condition which may result in
concurrency invocation of a Subscriber which is prohibited by the
Reactive Streams specification [1].

[1] https://github.com/reactive-streams/reactive-streams-jvm/blob/v1.0.3/README.md#1.3

Modifications:
- Use a DelayedSubscription so onSubscribe is invoked before the
  Subscriber reference is made visible to other threads which may
  invoke terminal methods on the Subscriber.

Result:
SpliceFlatStreamToMetaSingle is more compliant with RS spec and provides
more predictable behavior.
Copy link
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

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

🚀

@Scottmitch Scottmitch merged commit 7a5770f into apple:main Sep 29, 2021
@Scottmitch Scottmitch deleted the splice_race branch September 29, 2021 03:27
Scottmitch added a commit that referenced this pull request Sep 29, 2021
Motivation:
SpliceFlatStreamToMetaSingle has a race condition which may result in
concurrency invocation of a Subscriber which is prohibited by the
Reactive Streams specification [1].

[1] https://github.com/reactive-streams/reactive-streams-jvm/blob/v1.0.3/README.md#1.3

Modifications:
- Use a DelayedSubscription so onSubscribe is invoked before the
  Subscriber reference is made visible to other threads which may
  invoke terminal methods on the Subscriber.

Result:
SpliceFlatStreamToMetaSingle is more compliant with RS spec and provides
more predictable behavior.
@Scottmitch
Copy link
Member Author

0.41 (66eb875)

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