question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

flatMap, concatMap problem on Android 26

See original GitHub issue

I am using the lastest version RxJava, and I found that below code run on android 26 has problem-lose event.

Observable.create(new ObservableOnSubscribe<Integer>() {
            @Override
            public void subscribe(ObservableEmitter<Integer> e) throws Exception {
                e.onNext(1);
                e.onNext(2);
                e.onNext(3);
            }
        }).concatMap(new Function<Integer, ObservableSource<String>>() {
            @Override
            public ObservableSource<String> apply(Integer integer) throws Exception {
                List<String> list = new ArrayList<>();
                for (int i = 0; i < 3; i++) {
                    list.add("I am value " + integer);
                }
                int delayTime = (int) (1 + Math.random() * 10);
                return Observable.fromIterable(list).delay(delayTime, TimeUnit.MILLISECONDS);
            }
        }).subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<String>() {
                    @Override
                    public void accept(String s) throws Exception {
                        Log.i(TAG, "concatMap: accept:" + s);
                    }
                });

The run result on android-26(Android 8 emulator)(every observable lose a event):

07-30 15:13:54.354 11726-11726/? I/MainActivity: concatMap: accept:I am value 1
07-30 15:13:54.354 11726-11726/? I/MainActivity: concatMap: accept:I am value 1
07-30 15:13:54.354 11726-11726/? I/MainActivity: concatMap: accept:I am value 2
07-30 15:13:54.354 11726-11726/? I/MainActivity: concatMap: accept:I am value 2
07-30 15:13:54.354 11726-11726/? I/MainActivity: concatMap: accept:I am value 3
07-30 15:13:54.354 11726-11726/? I/MainActivity: concatMap: accept:I am value 3

The run result on android-25(Android 7.1 emulator):

07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 1
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 1
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 1
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 2
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 2
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 2
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 3
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 3
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 3

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
akarnokdcommented, Jul 30, 2017

Looks like there is a feature that hides/ignores duplicate log lines. I get this for the missing entries:

com.example.akarnokd.myapp I/chatty: uid=10082(u0_a82) com.example.akarnokd.myapp identical 1 line

If I change the printed item:

"I am value " + integer + " / " + i

I get all items.

Stackoverflow.

0reactions
xch168commented, Jul 30, 2017

Ok, I got. Thank you very much. 😊

Read more comments on GitHub >

github_iconTop Results From Across the Web

RxJava - flatmap vs concatMap - why is ordering the same on ...
So i did a test and created a simple stream of integers and wanted to see in what order they would be emitted....
Read more >
Unordered sequence when using a map in a zip #3221 - GitHub
I'm having a weird issue with RxJava where items come in the wrong order when one of the zip sources is doing a...
Read more >
Transform: FlatMap and ConcatMap - Educative.io
The .flatMap() operator is another very common operator used to transform emissions from an Observable . The stream is transformed by applying a...
Read more >
Understanding Map, FlatMap, SwitchMap and ConcatMap | by ...
FlatMap can interleave items while emitting i.e the emitted items order is not maintained. ConcatMap preserves the order of items.
Read more >
40 RxJava interview questions (and answers) - Vesko Iliev
What error handling operators do you know in RxJava? ... What's the difference between flatMap(), concatMap() and switchMap()?.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found