diff --git a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingCompletableObserverImpl.java b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingCompletableObserverImpl.java index 7d0b36dca..bd2e4d863 100755 --- a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingCompletableObserverImpl.java +++ b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingCompletableObserverImpl.java @@ -52,7 +52,6 @@ final class AutoDisposingCompletableObserverImpl implements AutoDisposingComplet } @Override public void onComplete() { - mainDisposable.lazySet(AutoDisposableHelper.DISPOSED); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); // Noop - we're unbound now } diff --git a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingMaybeObserverImpl.java b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingMaybeObserverImpl.java index 73010a7d5..f2e713dbe 100755 --- a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingMaybeObserverImpl.java +++ b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingMaybeObserverImpl.java @@ -52,7 +52,6 @@ final class AutoDisposingMaybeObserverImpl implements AutoDisposingMaybeObser } @Override public void onComplete() { - mainDisposable.lazySet(AutoDisposableHelper.DISPOSED); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); // Noop - we're unbound now } diff --git a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingObserverImpl.java b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingObserverImpl.java index 8aed379df..67f2ad3b4 100755 --- a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingObserverImpl.java +++ b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingObserverImpl.java @@ -54,7 +54,6 @@ final class AutoDisposingObserverImpl extends AtomicInteger implements AutoDi } @Override public void onComplete() { - mainDisposable.lazySet(AutoDisposableHelper.DISPOSED); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); // Noop - we're unbound now } diff --git a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingSingleObserverImpl.java b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingSingleObserverImpl.java index 324626a42..1301b2909 100755 --- a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingSingleObserverImpl.java +++ b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingSingleObserverImpl.java @@ -52,7 +52,6 @@ final class AutoDisposingSingleObserverImpl implements AutoDisposingSingleObs } @Override public void onComplete() { - mainDisposable.lazySet(AutoDisposableHelper.DISPOSED); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); // Noop - we're unbound now } diff --git a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingSubscriberImpl.java b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingSubscriberImpl.java index bba5334da..fb12773b3 100755 --- a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingSubscriberImpl.java +++ b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingSubscriberImpl.java @@ -59,7 +59,6 @@ final class AutoDisposingSubscriberImpl extends AtomicInteger } @Override public void onComplete() { - mainSubscription.lazySet(AutoSubscriptionHelper.CANCELLED); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); // Noop - we're unbound now } diff --git a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeCompletableObserverTest.java b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeCompletableObserverTest.java index 25286832a..592f10e05 100755 --- a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeCompletableObserverTest.java +++ b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeCompletableObserverTest.java @@ -320,12 +320,13 @@ public CompletableObserver apply(Completable source, CompletableObserver observe assertThat(atomicAutoDisposingObserver.get()).isNotNull(); assertThat(atomicAutoDisposingObserver.get()).isInstanceOf( AutoDisposingCompletableObserver.class); - assertThat(((AutoDisposingCompletableObserver) atomicAutoDisposingObserver.get()) - .delegateObserver()) + assertThat( + ((AutoDisposingCompletableObserver) atomicAutoDisposingObserver.get()).delegateObserver()) .isNotNull(); - assertThat(((AutoDisposingCompletableObserver) atomicAutoDisposingObserver.get()) - .delegateObserver()) - .isSameAs(atomicObserver.get()); + assertThat( + ((AutoDisposingCompletableObserver) atomicAutoDisposingObserver.get()).delegateObserver()) + .isSameAs( + atomicObserver.get()); } finally { RxJavaPlugins.reset(); } @@ -361,11 +362,23 @@ public CompletableObserver apply(Completable source, CompletableObserver observe @Test public void autoDispose_withScopeProviderCompleted_shouldNotReportDoubleSubscriptions() { TestObserver o = new TestObserver<>(); CompletableSubject.create() - .to(AutoDispose.with(ScopeProvider.UNBOUND).forCompletable()) + .to(AutoDispose.with(ScopeProvider.UNBOUND) + .forCompletable()) .subscribe(o); o.assertNoValues(); o.assertNoErrors(); rule.assertNoErrors(); } + + @Test public void unbound_shouldStillPassValues() { + TestObserver o = new TestObserver<>(); + CompletableSubject s = CompletableSubject.create(); + s.to(AutoDispose.with(ScopeProvider.UNBOUND) + .forCompletable()) + .subscribe(o); + + s.onComplete(); + o.assertComplete(); + } } diff --git a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeMaybeObserverTest.java b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeMaybeObserverTest.java index 1e56f1365..610aaa3cf 100755 --- a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeMaybeObserverTest.java +++ b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeMaybeObserverTest.java @@ -351,11 +351,11 @@ public class AutoDisposeMaybeObserverTest { assertThat(atomicAutoDisposingObserver.get()).isNotNull(); assertThat(atomicAutoDisposingObserver.get()).isInstanceOf(AutoDisposingMaybeObserver.class); - assertThat(((AutoDisposingMaybeObserver) atomicAutoDisposingObserver.get()) - .delegateObserver()) + assertThat( + ((AutoDisposingMaybeObserver) atomicAutoDisposingObserver.get()).delegateObserver()) .isNotNull(); - assertThat(((AutoDisposingMaybeObserver) atomicAutoDisposingObserver.get()) - .delegateObserver()) + assertThat( + ((AutoDisposingMaybeObserver) atomicAutoDisposingObserver.get()).delegateObserver()) .isSameAs(atomicObserver.get()); } finally { RxJavaPlugins.reset(); @@ -391,11 +391,22 @@ public class AutoDisposeMaybeObserverTest { @Test public void autoDispose_withScopeProviderCompleted_shouldNotReportDoubleSubscriptions() { TestObserver o = new TestObserver<>(); MaybeSubject.create() - .to(AutoDispose.with(ScopeProvider.UNBOUND).forMaybe()) + .to(AutoDispose.with(ScopeProvider.UNBOUND) + .forMaybe()) .subscribe(o); o.assertNoValues(); o.assertNoErrors(); rule.assertNoErrors(); } + + @Test public void unbound_shouldStillPassValues() { + TestObserver o = new TestObserver<>(); + MaybeSubject s = MaybeSubject.create(); + s.to(AutoDispose.with(ScopeProvider.UNBOUND).forMaybe()) + .subscribe(o); + + s.onSuccess(1); + o.assertValue(1); + } } diff --git a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeObserverTest.java b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeObserverTest.java index 9274e0e9d..7344a834b 100755 --- a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeObserverTest.java +++ b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeObserverTest.java @@ -337,4 +337,15 @@ public class AutoDisposeObserverTest { rule.assertNoErrors(); } + + @Test public void unbound_shouldStillPassValues() { + TestObserver o = new TestObserver<>(); + PublishSubject s = PublishSubject.create(); + s.to(AutoDispose.with(ScopeProvider.UNBOUND).forObservable()) + .subscribe(o); + + s.onNext(1); + o.assertValue(1); + o.dispose(); + } } diff --git a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSingleObserverTest.java b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSingleObserverTest.java index 2dc4a0ead..75210a629 100755 --- a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSingleObserverTest.java +++ b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSingleObserverTest.java @@ -321,11 +321,11 @@ public class AutoDisposeSingleObserverTest { assertThat(atomicAutoDisposingObserver.get()).isNotNull(); assertThat(atomicAutoDisposingObserver.get()).isInstanceOf(AutoDisposingSingleObserver.class); - assertThat(((AutoDisposingSingleObserver) atomicAutoDisposingObserver.get()) - .delegateObserver()) + assertThat( + ((AutoDisposingSingleObserver) atomicAutoDisposingObserver.get()).delegateObserver()) .isNotNull(); - assertThat(((AutoDisposingSingleObserver) atomicAutoDisposingObserver.get()) - .delegateObserver()) + assertThat( + ((AutoDisposingSingleObserver) atomicAutoDisposingObserver.get()).delegateObserver()) .isSameAs(atomicObserver.get()); } finally { RxJavaPlugins.reset(); @@ -361,11 +361,22 @@ public class AutoDisposeSingleObserverTest { @Test public void autoDispose_withScopeProviderCompleted_shouldNotReportDoubleSubscriptions() { TestObserver o = new TestObserver<>(); SingleSubject.create() - .to(AutoDispose.with(ScopeProvider.UNBOUND).forSingle()) + .to(AutoDispose.with(ScopeProvider.UNBOUND) + .forSingle()) .subscribe(o); o.assertNoValues(); o.assertNoErrors(); rule.assertNoErrors(); } + + @Test public void unbound_shouldStillPassValues() { + TestObserver o = new TestObserver<>(); + SingleSubject s = SingleSubject.create(); + s.to(AutoDispose.with(ScopeProvider.UNBOUND).forSingle()) + .subscribe(o); + + s.onSuccess(1); + o.assertValue(1); + } } diff --git a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSubscriberTest.java b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSubscriberTest.java index f0349af28..9652fe49f 100755 --- a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSubscriberTest.java +++ b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSubscriberTest.java @@ -296,11 +296,11 @@ public class AutoDisposeSubscriberTest { assertThat(atomicAutoDisposingSubscriber.get()).isNotNull(); assertThat(atomicAutoDisposingSubscriber.get()).isInstanceOf(AutoDisposingSubscriber.class); - assertThat(((AutoDisposingSubscriber) atomicAutoDisposingSubscriber.get()) - .delegateSubscriber()) + assertThat( + ((AutoDisposingSubscriber) atomicAutoDisposingSubscriber.get()).delegateSubscriber()) .isNotNull(); - assertThat(((AutoDisposingSubscriber) atomicAutoDisposingSubscriber.get()) - .delegateSubscriber()) + assertThat( + ((AutoDisposingSubscriber) atomicAutoDisposingSubscriber.get()).delegateSubscriber()) .isSameAs(atomicSubscriber.get()); } finally { RxJavaPlugins.reset(); @@ -341,11 +341,23 @@ public class AutoDisposeSubscriberTest { @Test public void autoDispose_withScopeProviderCompleted_shouldNotReportDoubleSubscriptions() { TestSubscriber o = new TestSubscriber<>(); PublishProcessor.create() - .to(AutoDispose.with(ScopeProvider.UNBOUND).forFlowable()) + .to(AutoDispose.with(ScopeProvider.UNBOUND) + .forFlowable()) .subscribe(o); o.assertNoValues(); o.assertNoErrors(); rule.assertNoErrors(); } + + @Test public void unbound_shouldStillPassValues() { + TestSubscriber o = new TestSubscriber<>(); + PublishProcessor s = PublishProcessor.create(); + s.to(AutoDispose.with(ScopeProvider.UNBOUND).forFlowable()) + .subscribe(o); + + s.onNext(1); + o.assertValue(1); + o.dispose(); + } }