package o; import io.reactivex.rxjava3.exceptions.CompositeException; import java.util.concurrent.atomic.AtomicReference; /* loaded from: classes6.dex */ public final class fYG extends AtomicReference implements InterfaceC13158fSf, InterfaceC15337gnm, fSJ { private fSQ a; private fSQ b; private fSP c; private fSQ d; public fYG(fSQ fsq, fSQ fsq2, fSP fsp, fSQ fsq3) { this.a = fsq; this.b = fsq2; this.c = fsp; this.d = fsq3; } @Override // o.InterfaceC13158fSf, o.InterfaceC15338gnn public final void c(InterfaceC15337gnm interfaceC15337gnm) { if (fYC.c(this, interfaceC15337gnm)) { try { this.d.c(this); } catch (Throwable th) { C13147fSI.c(th); interfaceC15337gnm.a(); onError(th); } } } @Override // o.InterfaceC15338gnn public final void onNext(T t) { if (isDisposed()) { return; } try { this.a.c(t); } catch (Throwable th) { C13147fSI.c(th); get().a(); onError(th); } } @Override // o.InterfaceC15338gnn public final void onError(Throwable th) { if (get() != fYC.CANCELLED) { lazySet(fYC.CANCELLED); try { this.b.c(th); return; } catch (Throwable th2) { C13147fSI.c(th2); C13418fZu.c(new CompositeException(th, th2)); return; } } C13418fZu.c(th); } @Override // o.InterfaceC15338gnn public final void onComplete() { if (get() != fYC.CANCELLED) { lazySet(fYC.CANCELLED); try { this.c.c(); } catch (Throwable th) { C13147fSI.c(th); C13418fZu.c(th); } } } @Override // o.fSJ public final boolean isDisposed() { return get() == fYC.CANCELLED; } @Override // o.InterfaceC15337gnm public final void c(long j) { get().c(j); } @Override // o.InterfaceC15337gnm public final void a() { fYC.c(this); } @Override // o.fSJ public final void dispose() { fYC.c(this); } }