package o; import java.util.concurrent.atomic.AtomicReference; /* renamed from: o.fZg, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public class C13404fZg extends AbstractC13402fZe> implements InterfaceC13174fSv, fSJ, InterfaceC13161fSi, InterfaceC13176fSx, InterfaceC13154fSb { private final InterfaceC13174fSv h; private final AtomicReference i; /* renamed from: o.fZg$IeS */ /* loaded from: classes6.dex */ enum IeS implements InterfaceC13174fSv { INSTANCE; @Override // o.InterfaceC13174fSv public final void onComplete() { } @Override // o.InterfaceC13174fSv public final void onError(Throwable th) { } @Override // o.InterfaceC13174fSv public final void onNext(Object obj) { } @Override // o.InterfaceC13174fSv public final void onSubscribe(fSJ fsj) { } } public C13404fZg() { this(IeS.INSTANCE); } private C13404fZg(InterfaceC13174fSv interfaceC13174fSv) { this.i = new AtomicReference<>(); this.h = interfaceC13174fSv; } @Override // o.InterfaceC13174fSv public void onSubscribe(fSJ fsj) { this.b = Thread.currentThread(); if (fsj == null) { this.d.add(new NullPointerException("onSubscribe received a null Subscription")); return; } AtomicReference atomicReference = this.i; while (!atomicReference.compareAndSet(null, fsj)) { if (atomicReference.get() != null) { fsj.dispose(); if (this.i.get() != EnumC13192fTf.DISPOSED) { this.d.add(new IllegalStateException("onSubscribe received multiple subscriptions: ".concat(String.valueOf(fsj)))); return; } return; } } this.h.onSubscribe(fsj); } @Override // o.InterfaceC13174fSv public void onNext(T t) { if (!this.c) { this.c = true; if (this.i.get() == null) { this.d.add(new IllegalStateException("onSubscribe not called in proper order")); } } this.b = Thread.currentThread(); this.f.add(t); if (t == null) { this.d.add(new NullPointerException("onNext received a null value")); } this.h.onNext(t); } @Override // o.InterfaceC13174fSv public void onError(Throwable th) { if (!this.c) { this.c = true; if (this.i.get() == null) { this.d.add(new IllegalStateException("onSubscribe not called in proper order")); } } try { this.b = Thread.currentThread(); if (th == null) { this.d.add(new NullPointerException("onError received a null Throwable")); } else { this.d.add(th); } this.h.onError(th); } finally { this.a.countDown(); } } @Override // o.InterfaceC13174fSv public void onComplete() { if (!this.c) { this.c = true; if (this.i.get() == null) { this.d.add(new IllegalStateException("onSubscribe not called in proper order")); } } try { this.b = Thread.currentThread(); this.e++; this.h.onComplete(); } finally { this.a.countDown(); } } @Override // o.fSJ public final void dispose() { EnumC13192fTf.e(this.i); } @Override // o.fSJ public final boolean isDisposed() { return EnumC13192fTf.c(this.i.get()); } @Override // o.InterfaceC13161fSi public final void e(T t) { onNext(t); onComplete(); } }