diff --git a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingCompletableObserverImpl.java b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingCompletableObserverImpl.java index ad28fccae..b2c728f10 100755 --- a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingCompletableObserverImpl.java +++ b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingCompletableObserverImpl.java @@ -20,7 +20,6 @@ import io.reactivex.CompletableObserver; import io.reactivex.Maybe; import io.reactivex.disposables.Disposable; -import io.reactivex.disposables.Disposables; import io.reactivex.observers.DisposableMaybeObserver; import java.util.concurrent.atomic.AtomicReference; @@ -43,30 +42,26 @@ final class AutoDisposingCompletableObserverImpl implements AutoDisposingComplet @Override public void onSubscribe(final Disposable d) { DisposableMaybeObserver o = new DisposableMaybeObserver() { @Override public void onSuccess(Object o) { - callMainSubscribeIfNecessary(d); AutoDisposableHelper.dispose(mainDisposable); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); } @Override public void onError(Throwable e) { - callMainSubscribeIfNecessary(d); AutoDisposingCompletableObserverImpl.this.onError(e); mainDisposable.lazySet(AutoDisposableHelper.DISPOSED); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); } @Override public void onComplete() { - callMainSubscribeIfNecessary(d); mainDisposable.lazySet(AutoDisposableHelper.DISPOSED); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); // Noop - we're unbound now } }; if (AutoDisposeEndConsumerHelper.setOnce(lifecycleDisposable, o, getClass())) { + delegate.onSubscribe(this); lifecycle.subscribe(o); - if (AutoDisposeEndConsumerHelper.setOnce(mainDisposable, d, getClass())) { - delegate.onSubscribe(this); - } + AutoDisposeEndConsumerHelper.setOnce(mainDisposable, d, getClass()); } } @@ -79,16 +74,6 @@ final class AutoDisposingCompletableObserverImpl implements AutoDisposingComplet AutoDisposableHelper.dispose(mainDisposable); } - @SuppressWarnings("WeakerAccess") // Avoiding synthetic accessors - void callMainSubscribeIfNecessary(Disposable d) { - // If we've never actually called the downstream onSubscribe (i.e. requested immediately in - // onSubscribe and had a terminal event), we need to still send an empty disposable instance - // to abide by the Observer contract. - if (AutoDisposableHelper.setIfNotSet(mainDisposable, d)) { - delegate.onSubscribe(Disposables.disposed()); - } - } - @Override public void onComplete() { if (!isDisposed()) { AutoDisposableHelper.dispose(lifecycleDisposable); diff --git a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingMaybeObserverImpl.java b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingMaybeObserverImpl.java index 58a6a740d..be8f3ac77 100755 --- a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingMaybeObserverImpl.java +++ b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingMaybeObserverImpl.java @@ -20,7 +20,6 @@ import io.reactivex.Maybe; import io.reactivex.MaybeObserver; import io.reactivex.disposables.Disposable; -import io.reactivex.disposables.Disposables; import io.reactivex.observers.DisposableMaybeObserver; import java.util.concurrent.atomic.AtomicReference; @@ -43,30 +42,26 @@ final class AutoDisposingMaybeObserverImpl implements AutoDisposingMaybeObser @Override public void onSubscribe(final Disposable d) { DisposableMaybeObserver o = new DisposableMaybeObserver() { @Override public void onSuccess(Object o) { - callMainSubscribeIfNecessary(d); AutoDisposableHelper.dispose(mainDisposable); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); } @Override public void onError(Throwable e) { - callMainSubscribeIfNecessary(d); AutoDisposingMaybeObserverImpl.this.onError(e); mainDisposable.lazySet(AutoDisposableHelper.DISPOSED); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); } @Override public void onComplete() { - callMainSubscribeIfNecessary(d); mainDisposable.lazySet(AutoDisposableHelper.DISPOSED); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); // Noop - we're unbound now } }; if (AutoDisposeEndConsumerHelper.setOnce(lifecycleDisposable, o, getClass())) { + delegate.onSubscribe(this); lifecycle.subscribe(o); - if (AutoDisposeEndConsumerHelper.setOnce(mainDisposable, d, getClass())) { - delegate.onSubscribe(this); - } + AutoDisposeEndConsumerHelper.setOnce(mainDisposable, d, getClass()); } } @@ -79,16 +74,6 @@ final class AutoDisposingMaybeObserverImpl implements AutoDisposingMaybeObser AutoDisposableHelper.dispose(mainDisposable); } - @SuppressWarnings("WeakerAccess") // Avoiding synthetic accessors - void callMainSubscribeIfNecessary(Disposable d) { - // If we've never actually called the downstream onSubscribe (i.e. requested immediately in - // onSubscribe and had a terminal event), we need to still send an empty disposable instance - // to abide by the Observer contract. - if (AutoDisposableHelper.setIfNotSet(mainDisposable, d)) { - delegate.onSubscribe(Disposables.disposed()); - } - } - @Override public void onSuccess(T value) { if (!isDisposed()) { AutoDisposableHelper.dispose(lifecycleDisposable); diff --git a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingObserverImpl.java b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingObserverImpl.java index d4c234c0f..33f47ba98 100755 --- a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingObserverImpl.java +++ b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingObserverImpl.java @@ -20,7 +20,6 @@ import io.reactivex.Maybe; import io.reactivex.Observer; import io.reactivex.disposables.Disposable; -import io.reactivex.disposables.Disposables; import io.reactivex.observers.DisposableMaybeObserver; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; @@ -45,30 +44,26 @@ final class AutoDisposingObserverImpl extends AtomicInteger implements AutoDi @Override public void onSubscribe(final Disposable d) { DisposableMaybeObserver o = new DisposableMaybeObserver() { @Override public void onSuccess(Object o) { - callMainSubscribeIfNecessary(d); AutoDisposableHelper.dispose(mainDisposable); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); } @Override public void onError(Throwable e) { - callMainSubscribeIfNecessary(d); AutoDisposingObserverImpl.this.onError(e); mainDisposable.lazySet(AutoDisposableHelper.DISPOSED); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); } @Override public void onComplete() { - callMainSubscribeIfNecessary(d); mainDisposable.lazySet(AutoDisposableHelper.DISPOSED); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); // Noop - we're unbound now } }; if (AutoDisposeEndConsumerHelper.setOnce(lifecycleDisposable, o, getClass())) { + delegate.onSubscribe(this); lifecycle.subscribe(o); - if (AutoDisposeEndConsumerHelper.setOnce(mainDisposable, d, getClass())) { - delegate.onSubscribe(this); - } + AutoDisposeEndConsumerHelper.setOnce(mainDisposable, d, getClass()); } } @@ -81,16 +76,6 @@ final class AutoDisposingObserverImpl extends AtomicInteger implements AutoDi AutoDisposableHelper.dispose(mainDisposable); } - @SuppressWarnings("WeakerAccess") // Avoiding synthetic accessors - void callMainSubscribeIfNecessary(Disposable d) { - // If we've never actually called the downstream onSubscribe (i.e. requested immediately in - // onSubscribe and had a terminal event), we need to still send an empty disposable instance - // to abide by the Observer contract. - if (AutoDisposableHelper.setIfNotSet(mainDisposable, d)) { - delegate.onSubscribe(Disposables.disposed()); - } - } - @Override public void onNext(T value) { if (!isDisposed()) { if (HalfSerializer.onNext(delegate, value, this, error)) { diff --git a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingSingleObserverImpl.java b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingSingleObserverImpl.java index dbc6cb659..885f3fb81 100755 --- a/autodispose/src/main/java/com/uber/autodispose/AutoDisposingSingleObserverImpl.java +++ b/autodispose/src/main/java/com/uber/autodispose/AutoDisposingSingleObserverImpl.java @@ -20,7 +20,6 @@ import io.reactivex.Maybe; import io.reactivex.SingleObserver; import io.reactivex.disposables.Disposable; -import io.reactivex.disposables.Disposables; import io.reactivex.observers.DisposableMaybeObserver; import java.util.concurrent.atomic.AtomicReference; @@ -43,30 +42,26 @@ final class AutoDisposingSingleObserverImpl implements AutoDisposingSingleObs @Override public void onSubscribe(final Disposable d) { DisposableMaybeObserver o = new DisposableMaybeObserver() { @Override public void onSuccess(Object o) { - callMainSubscribeIfNecessary(d); AutoDisposableHelper.dispose(mainDisposable); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); } @Override public void onError(Throwable e) { - callMainSubscribeIfNecessary(d); AutoDisposingSingleObserverImpl.this.onError(e); mainDisposable.lazySet(AutoDisposableHelper.DISPOSED); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); } @Override public void onComplete() { - callMainSubscribeIfNecessary(d); mainDisposable.lazySet(AutoDisposableHelper.DISPOSED); lifecycleDisposable.lazySet(AutoDisposableHelper.DISPOSED); // Noop - we're unbound now } }; if (AutoDisposeEndConsumerHelper.setOnce(lifecycleDisposable, o, getClass())) { + delegate.onSubscribe(this); lifecycle.subscribe(o); - if (AutoDisposeEndConsumerHelper.setOnce(mainDisposable, d, getClass())) { - delegate.onSubscribe(this); - } + AutoDisposeEndConsumerHelper.setOnce(mainDisposable, d, getClass()); } } @@ -79,16 +74,6 @@ final class AutoDisposingSingleObserverImpl implements AutoDisposingSingleObs AutoDisposableHelper.dispose(mainDisposable); } - @SuppressWarnings("WeakerAccess") // Avoiding synthetic accessors - void callMainSubscribeIfNecessary(Disposable d) { - // If we've never actually called the downstream onSubscribe (i.e. requested immediately in - // onSubscribe and had a terminal event), we need to still send an empty disposable instance - // to abide by the Observer contract. - if (AutoDisposableHelper.setIfNotSet(mainDisposable, d)) { - delegate.onSubscribe(Disposables.disposed()); - } - } - @Override public void onSuccess(T value) { if (!isDisposed()) { AutoDisposableHelper.dispose(lifecycleDisposable);