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

2.x: Fix Flowable.take to route post-cancel errors to RxJavaPlugins.onError #5978

Merged
merged 1 commit into from
Apr 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import io.reactivex.*;
import io.reactivex.internal.subscriptions.*;
import io.reactivex.plugins.RxJavaPlugins;

public final class FlowableTake<T> extends AbstractFlowableWithUpstream<T, T> {
final long limit;
Expand Down Expand Up @@ -75,6 +76,8 @@ public void onError(Throwable t) {
done = true;
subscription.cancel();
actual.onError(t);
} else {
RxJavaPlugins.onError(t);
}
}
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,19 @@ public void run() {
ts.assertResult(1, 2, 3, 4, 5);
}
}

@Test
public void errorAfterLimitReached() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable.error(new TestException())
.limit(0)
.test()
.assertResult();

TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
package io.reactivex.internal.operators.flowable;

import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;

import java.util.Arrays;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;

Expand All @@ -28,6 +29,7 @@
import io.reactivex.exceptions.TestException;
import io.reactivex.functions.*;
import io.reactivex.internal.subscriptions.BooleanSubscription;
import io.reactivex.plugins.RxJavaPlugins;
import io.reactivex.processors.PublishProcessor;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subscribers.TestSubscriber;
Expand Down Expand Up @@ -495,4 +497,19 @@ public void run() {
ts.assertResult(1, 2);
}
}

@Test
public void errorAfterLimitReached() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable.error(new TestException())
.take(0)
.test()
.assertResult();

TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@
package io.reactivex.internal.operators.observable;

import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;

import java.util.Arrays;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.*;

import org.junit.*;
import org.mockito.InOrder;

import io.reactivex.*;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.disposables.*;
import io.reactivex.exceptions.TestException;
import io.reactivex.functions.*;
import io.reactivex.observers.TestObserver;
import io.reactivex.plugins.RxJavaPlugins;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subjects.PublishSubject;

Expand Down Expand Up @@ -389,4 +393,19 @@ public ObservableSource<Object> apply(Observable<Object> o) throws Exception {
}
});
}

@Test
public void errorAfterLimitReached() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Observable.error(new TestException())
.take(0)
.test()
.assertResult();

TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
}