package o; import io.reactivex.rxjava3.exceptions.CompositeException; import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; /* loaded from: classes6.dex */ public final class fXI extends AbstractC13163fSk { private fSS> a; private boolean b; private fSQ c; private InterfaceC13189fTc e; public fXI(InterfaceC13189fTc interfaceC13189fTc, fSS> fss, fSQ fsq, boolean z) { this.e = interfaceC13189fTc; this.a = fss; this.c = fsq; this.b = z; } @Override // o.AbstractC13163fSk public final void subscribeActual(InterfaceC13174fSv interfaceC13174fSv) { try { D d = this.e.d(); try { ((InterfaceC13169fSq) Objects.requireNonNull(this.a.a(d), "The sourceSupplier returned a null ObservableSource")).subscribe(new HBt(interfaceC13174fSv, d, this.c, this.b)); } catch (Throwable th) { C13147fSI.c(th); try { this.c.c(d); EnumC13195fTi.a(th, interfaceC13174fSv); } catch (Throwable th2) { C13147fSI.c(th2); EnumC13195fTi.a(new CompositeException(th, th2), interfaceC13174fSv); } } } catch (Throwable th3) { C13147fSI.c(th3); EnumC13195fTi.a(th3, interfaceC13174fSv); } } /* loaded from: classes6.dex */ static final class HBt extends AtomicBoolean implements InterfaceC13174fSv, fSJ { private fSJ a; private fSQ b; private boolean c; private InterfaceC13174fSv d; private D e; HBt(InterfaceC13174fSv interfaceC13174fSv, D d, fSQ fsq, boolean z) { this.d = interfaceC13174fSv; this.e = d; this.b = fsq; this.c = z; } @Override // o.InterfaceC13174fSv public final void onSubscribe(fSJ fsj) { if (EnumC13192fTf.d(this.a, fsj)) { this.a = fsj; this.d.onSubscribe(this); } } @Override // o.InterfaceC13174fSv public final void onNext(T t) { this.d.onNext(t); } @Override // o.InterfaceC13174fSv public final void onError(Throwable th) { if (this.c) { if (compareAndSet(false, true)) { try { this.b.c(this.e); } catch (Throwable th2) { C13147fSI.c(th2); th = new CompositeException(th, th2); } } this.d.onError(th); return; } this.d.onError(th); c(); } @Override // o.InterfaceC13174fSv public final void onComplete() { if (this.c) { if (compareAndSet(false, true)) { try { this.b.c(this.e); } catch (Throwable th) { C13147fSI.c(th); this.d.onError(th); return; } } this.d.onComplete(); return; } this.d.onComplete(); c(); } @Override // o.fSJ public final void dispose() { if (this.c) { c(); this.a.dispose(); this.a = EnumC13192fTf.DISPOSED; } else { this.a.dispose(); this.a = EnumC13192fTf.DISPOSED; c(); } } @Override // o.fSJ public final boolean isDisposed() { return get(); } private void c() { if (compareAndSet(false, true)) { try { this.b.c(this.e); } catch (Throwable th) { C13147fSI.c(th); C13418fZu.c(th); } } } } }