package d.a.s.e.c;

import a.a.a.a.c.n0;
import java.util.concurrent.atomic.AtomicReference;

/* JADX INFO: loaded from: classes.dex */
public final class b<T> extends d.a.h<T> {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final d.a.j<T> f5704b;

    public static final class a<T> extends AtomicReference<d.a.p.b> implements d.a.i<T>, d.a.p.b {

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public final d.a.l<? super T> f5705b;

        public a(d.a.l<? super T> lVar) {
            this.f5705b = lVar;
        }

        public void a() {
            if (isDisposed()) {
                return;
            }
            try {
                this.f5705b.b();
            } finally {
                d.a.s.a.b.dispose(this);
            }
        }

        public void b(T t) {
            if (t != null) {
                if (isDisposed()) {
                    return;
                }
                this.f5705b.d(t);
            } else {
                NullPointerException nullPointerException = new NullPointerException("onNext called with null. Null values are generally not allowed in 2.x operators and sources.");
                if (c(nullPointerException)) {
                    return;
                }
                d.a.u.a.w(nullPointerException);
            }
        }

        public boolean c(Throwable th) {
            if (th == null) {
                th = new NullPointerException("onError called with null. Null values are generally not allowed in 2.x operators and sources.");
            }
            if (isDisposed()) {
                return false;
            }
            try {
                this.f5705b.a(th);
                d.a.s.a.b.dispose(this);
                return true;
            } catch (Throwable th2) {
                d.a.s.a.b.dispose(this);
                throw th2;
            }
        }

        @Override // d.a.p.b
        public void dispose() {
            d.a.s.a.b.dispose(this);
        }

        @Override // d.a.p.b
        public boolean isDisposed() {
            return d.a.s.a.b.isDisposed(get());
        }

        @Override // java.util.concurrent.atomic.AtomicReference
        public String toString() {
            return String.format("%s{%s}", a.class.getSimpleName(), super.toString());
        }
    }

    public b(d.a.j<T> jVar) {
        this.f5704b = jVar;
    }

    @Override // d.a.h
    public void o(d.a.l<? super T> lVar) {
        a aVar = new a(lVar);
        lVar.c(aVar);
        try {
            this.f5704b.a(aVar);
        } catch (Throwable th) {
            n0.y(th);
            if (aVar.c(th)) {
                return;
            }
            d.a.u.a.w(th);
        }
    }
}
