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

Add support for backpressure to observables. #27

Merged
merged 1 commit into from
Aug 24, 2015
Merged

Add support for backpressure to observables. #27

merged 1 commit into from
Aug 24, 2015

Conversation

JakeWharton
Copy link
Contributor

Closes #26. Forgot about this for v1.0. Not urgent to make another release right away but this will bite people depending on the operators they use with these observables without this change.

@@ -0,0 +1,117 @@
/*
* Copyright (C) 2015 Square, Inc.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is copy/pasted from square/sqlbrite#35

final Producer producer = new Producer() {
@Override public void request(long n) {
if (n < 0) {
throw new IllegalArgumentException("requested " + n + " < 0");
Copy link
Owner

Choose a reason for hiding this comment

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

Curious, could this ever happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you accidentally overflow a long (requests usually are Long.MAX_VALUE so you could blindly add 1 and get negative) or are just off-by-one (or more) on some subtraction code for request. But it's unlikely to ever happen in practice. Most of this file is copied from an RxJava operator.

f2prateek added a commit that referenced this pull request Aug 24, 2015
Add support for backpressure to observables.
@f2prateek f2prateek merged commit faf5710 into f2prateek:master Aug 24, 2015
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