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

Using Observable toList() after takeWhile() fails in some cases #1451

Closed
spodila opened this issue Jul 16, 2014 · 1 comment
Closed

Using Observable toList() after takeWhile() fails in some cases #1451

spodila opened this issue Jul 16, 2014 · 1 comment

Comments

@spodila
Copy link
Contributor

spodila commented Jul 16, 2014

With the latest 0.20.0-RC1 a combination of takeWhile() and toList() on an Observable fails, sometimes.

Here's a unit test that fails:

@Test
    public void testTakeWhile() {
        int[] nums = {1, 2, 3};
        final AtomicInteger count = new AtomicInteger();
        for(final int n: nums) {
            Observable
                    .from(Boolean.TRUE, Boolean.FALSE)
                    .takeWhile(new Func1<Boolean, Boolean>() {
                        @Override
                        public Boolean call(Boolean value) {
                            return value;
                        }
                    })
                    .toList()
                    .doOnNext(new Action1<List<Boolean>>() {
                        @Override
                        public void call(List<Boolean> booleans) {
                            count.incrementAndGet();
                        }
                    })
                    .subscribe();
        }
        assertEquals(nums.length, count.get());
    }

Here's the same unit test that passes with slight modification:

@Test
    public void testTakeWhile() {
        int[] nums = {1, 2, 3};
        final AtomicInteger count = new AtomicInteger();
        for(final int n: nums) {
            Observable
                    .from(Boolean.TRUE, Boolean.FALSE, Boolean.FALSE)
                    .takeWhile(new Func1<Boolean, Boolean>() {
                        @Override
                        public Boolean call(Boolean value) {
                            return value;
                        }
                    })
                    .toList()
                    .doOnNext(new Action1<List<Boolean>>() {
                        @Override
                        public void call(List<Boolean> booleans) {
                            count.incrementAndGet();
                        }
                    })
                    .subscribe();
        }
        assertEquals(nums.length, count.get());
    }
zsxwing added a commit to zsxwing/RxJava that referenced this issue Jul 17, 2014
zsxwing added a commit to zsxwing/RxJava that referenced this issue Jul 17, 2014
zsxwing added a commit to zsxwing/RxJava that referenced this issue Jul 17, 2014
benjchristensen added a commit that referenced this issue Jul 17, 2014
@benjchristensen
Copy link
Member

This should be fixed in 0.20.0-RC3

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

2 participants