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 Observable.concatMapEager bad logic for immediate scalars #4982

Merged
merged 2 commits into from Jan 11, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -14,7 +14,6 @@
package io.reactivex.internal.operators.observable;

import java.util.ArrayDeque;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicInteger;

import io.reactivex.*;
Expand Down Expand Up @@ -218,7 +217,6 @@ public void innerComplete(InnerQueuedObserver<R> inner) {
drain();
}

@SuppressWarnings("unchecked")
@Override
public void drain() {
if (getAndIncrement() != 0) {
Expand Down Expand Up @@ -276,23 +274,6 @@ public void drain() {
return;
}

if (source instanceof Callable) {
R w;

try {
w = ((Callable<R>)source).call();
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
error.addThrowable(ex);
continue;
}

if (w != null) {
a.onNext(w);
}
continue;
}

InnerQueuedObserver<R> inner = new InnerQueuedObserver<R>(this, prefetch);

observers.offer(inner);
Expand Down
Expand Up @@ -1175,4 +1175,23 @@ public void innerLong() {
.assertComplete()
.assertNoErrors();
}

@Test
public void oneDelayed() {
Flowable.just(1, 2, 3, 4, 5)
.concatMapEager(new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer i) throws Exception {
System.out.println("Processing " + i);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just cluttering it up and can be removed?

return i == 3 ? Flowable.just(i) : Flowable
.just(i)
.delay(1, TimeUnit.MILLISECONDS, Schedulers.io());
}
})
.observeOn(Schedulers.io())
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertResult(1, 2, 3, 4, 5)
;
}
}
Expand Up @@ -983,4 +983,23 @@ public ObservableSource<Object> apply(Object v) throws Exception {
}
});
}

@Test
public void oneDelayed() {
Observable.just(1, 2, 3, 4, 5)
.concatMapEager(new Function<Integer, ObservableSource<Integer>>() {
@Override
public ObservableSource<Integer> apply(Integer i) throws Exception {
System.out.println("Processing " + i);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

return i == 3 ? Observable.just(i) : Observable
.just(i)
.delay(1, TimeUnit.MILLISECONDS, Schedulers.io());
}
})
.observeOn(Schedulers.io())
.test()
.awaitDone(5, TimeUnit.SECONDS)
.assertResult(1, 2, 3, 4, 5)
;
}
}