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

OperationTakeWhile doesn't protect calls to predicate #219

Closed
johngmyers opened this issue Apr 1, 2013 · 1 comment
Closed

OperationTakeWhile doesn't protect calls to predicate #219

johngmyers opened this issue Apr 1, 2013 · 1 comment

Comments

@johngmyers
Copy link
Contributor

Per RX guideline 6.4, calls to selector functions passed in to the operator should be caught and fed through to the subscribed observer. Operator TakeWhile doesn't do this with the passed in predicate.

        @Test
        public void testTakeWhileProtectsPredicateCall() {
            TestObservable source = new TestObservable(mock(Subscription.class), "one");
            final RuntimeException testException = new RuntimeException("test exception");

            @SuppressWarnings("unchecked")
            Observer<String> aObserver = mock(Observer.class);
            Observable<String> take = Observable.create(takeWhile(source, new Func1<String, Boolean>()
            {
                @Override
                public Boolean call(String s)
                {
                    throw testException;
                }
            }));
            take.subscribe(aObserver);

            // wait for the Observable to complete
            try {
                source.t.join();
            } catch (Exception e) {
                e.printStackTrace();
                fail(e.getMessage());
            }

            verify(aObserver, never()).onNext(any(String.class));
            verify(aObserver, times(1)).onError(testException);
        }
@johngmyers
Copy link
Contributor Author

Might as well supply the fix. Sent pull #220.

jihoonson pushed a commit to jihoonson/RxJava that referenced this issue Mar 6, 2020
* ReactiveX#186: Feature:allow full reset of circuit breakers

* ReactiveX#186 Renaming reset and splitting events

Split reset behaviour from state transition
Sending up to two events in case of reset (state transition if any, reset)

* 218 fix in builder in CircuitBreakerConfig
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

No branches or pull requests

1 participant