Skip to content
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 @@ -114,9 +114,10 @@ void drain() {

AtomicReference<Object> c = current;
Subscriber<? super T> a = actual;
Disposable cancelled = disposables;

for (;;) {
if (disposables.isDisposed()) {
if (cancelled.isDisposed()) {
c.lazySet(null);
return;
}
Expand All @@ -141,7 +142,7 @@ void drain() {
c.lazySet(null);
}

if (goNextSource) {
if (goNextSource && !cancelled.isDisposed()) {
int i = index;
if (i == sources.length) {
a.onComplete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ void drain() {

AtomicReference<Object> c = current;
Subscriber<? super T> a = actual;
Disposable cancelled = disposables;

for (;;) {
if (disposables.isDisposed()) {
if (cancelled.isDisposed()) {
c.lazySet(null);
return;
}
Expand All @@ -151,7 +152,7 @@ void drain() {
c.lazySet(null);
}

if (goNextSource) {
if (goNextSource && !cancelled.isDisposed()) {
int i = index;
if (i == sources.length) {
Throwable ex = errors.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ void drain() {

AtomicReference<Object> c = current;
Subscriber<? super T> a = actual;
Disposable cancelled = disposables;

for (;;) {
if (disposables.isDisposed()) {
if (cancelled.isDisposed()) {
c.lazySet(null);
return;
}
Expand All @@ -153,7 +154,7 @@ void drain() {
c.lazySet(null);
}

if (goNextSource) {
if (goNextSource && !cancelled.isDisposed()) {
boolean b;

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1542,4 +1542,88 @@ public Publisher<Object> apply(Integer v) throws Exception {
.test()
.assertFailure(TestException.class);
}

@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscription() {
final int[] calls = { 0 };

Flowable<Integer> source = Flowable.create(new FlowableOnSubscribe<Integer>() {
@Override
public void subscribe(FlowableEmitter<Integer> s) throws Exception {
calls[0]++;
s.onNext(1);
s.onComplete();
}
}, BackpressureStrategy.MISSING);

Flowable.concatArray(source, source).firstElement()
.test()
.assertResult(1);

assertEquals(1, calls[0]);
}

@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscriptionDelayError() {
final int[] calls = { 0 };

Flowable<Integer> source = Flowable.create(new FlowableOnSubscribe<Integer>() {
@Override
public void subscribe(FlowableEmitter<Integer> s) throws Exception {
calls[0]++;
s.onNext(1);
s.onComplete();
}
}, BackpressureStrategy.MISSING);

Flowable.concatArrayDelayError(source, source).firstElement()
.test()
.assertResult(1);

assertEquals(1, calls[0]);
}

@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscriptionIterable() {
final int[] calls = { 0 };

Flowable<Integer> source = Flowable.create(new FlowableOnSubscribe<Integer>() {
@Override
public void subscribe(FlowableEmitter<Integer> s) throws Exception {
calls[0]++;
s.onNext(1);
s.onComplete();
}
}, BackpressureStrategy.MISSING);

Flowable.concat(Arrays.asList(source, source)).firstElement()
.test()
.assertResult(1);

assertEquals(1, calls[0]);
}

@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscriptionDelayErrorIterable() {
final int[] calls = { 0 };

Flowable<Integer> source = Flowable.create(new FlowableOnSubscribe<Integer>() {
@Override
public void subscribe(FlowableEmitter<Integer> s) throws Exception {
calls[0]++;
s.onNext(1);
s.onComplete();
}
}, BackpressureStrategy.MISSING);

Flowable.concatDelayError(Arrays.asList(source, source)).firstElement()
.test()
.assertResult(1);

assertEquals(1, calls[0]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.io.IOException;
import java.util.List;

import static org.junit.Assert.*;
import org.junit.Test;

import io.reactivex.*;
Expand Down Expand Up @@ -156,4 +157,44 @@ protected void subscribeActual(MaybeObserver<? super Integer> observer) {
RxJavaPlugins.reset();
}
}

@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscription() {
final int[] calls = { 0 };

Maybe<Integer> source = Maybe.create(new MaybeOnSubscribe<Integer>() {
@Override
public void subscribe(MaybeEmitter<Integer> s) throws Exception {
calls[0]++;
s.onSuccess(1);
}
});

Maybe.concatArray(source, source).firstElement()
.test()
.assertResult(1);

assertEquals(1, calls[0]);
}

@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscriptionDelayError() {
final int[] calls = { 0 };

Maybe<Integer> source = Maybe.create(new MaybeOnSubscribe<Integer>() {
@Override
public void subscribe(MaybeEmitter<Integer> s) throws Exception {
calls[0]++;
s.onSuccess(1);
}
});

Maybe.concatArrayDelayError(source, source).firstElement()
.test()
.assertResult(1);

assertEquals(1, calls[0]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package io.reactivex.internal.operators.maybe;

import static org.junit.Assert.assertEquals;

import java.util.*;

import org.junit.Test;
Expand Down Expand Up @@ -121,4 +123,44 @@ public Maybe<Integer> apply(Integer v) throws Exception {
.test()
.assertFailure(NullPointerException.class);
}

@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscription() {
final int[] calls = { 0 };

Maybe<Integer> source = Maybe.create(new MaybeOnSubscribe<Integer>() {
@Override
public void subscribe(MaybeEmitter<Integer> s) throws Exception {
calls[0]++;
s.onSuccess(1);
}
});

Maybe.concat(Arrays.asList(source, source)).firstElement()
.test()
.assertResult(1);

assertEquals(1, calls[0]);
}

@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscriptionDelayError() {
final int[] calls = { 0 };

Maybe<Integer> source = Maybe.create(new MaybeOnSubscribe<Integer>() {
@Override
public void subscribe(MaybeEmitter<Integer> s) throws Exception {
calls[0]++;
s.onSuccess(1);
}
});

Maybe.concatDelayError(Arrays.asList(source, source)).firstElement()
.test()
.assertResult(1);

assertEquals(1, calls[0]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -958,4 +958,87 @@ public ObservableSource<Integer> apply(Object v) throws Exception {

}

@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscription() {
final int[] calls = { 0 };

Observable<Integer> source = Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> s) throws Exception {
calls[0]++;
s.onNext(1);
s.onComplete();
}
});

Observable.concatArray(source, source).firstElement()
.test()
.assertResult(1);

assertEquals(1, calls[0]);
}

@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscriptionDelayError() {
final int[] calls = { 0 };

Observable<Integer> source = Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> s) throws Exception {
calls[0]++;
s.onNext(1);
s.onComplete();
}
});

Observable.concatArrayDelayError(source, source).firstElement()
.test()
.assertResult(1);

assertEquals(1, calls[0]);
}

@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscriptionIterable() {
final int[] calls = { 0 };

Observable<Integer> source = Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> s) throws Exception {
calls[0]++;
s.onNext(1);
s.onComplete();
}
});

Observable.concat(Arrays.asList(source, source)).firstElement()
.test()
.assertResult(1);

assertEquals(1, calls[0]);
}

@SuppressWarnings("unchecked")
@Test
public void noSubsequentSubscriptionDelayErrorIterable() {
final int[] calls = { 0 };

Observable<Integer> source = Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> s) throws Exception {
calls[0]++;
s.onNext(1);
s.onComplete();
}
});

Observable.concatDelayError(Arrays.asList(source, source)).firstElement()
.test()
.assertResult(1);

assertEquals(1, calls[0]);
}
}
Loading