package retrofit2.adapter.rxjava3; import io.reactivex.rxjava3.exceptions.CompositeException; import o.AbstractC13163fSk; import o.C13147fSI; import o.C13418fZu; import o.InterfaceC13174fSv; import o.fSJ; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; /* loaded from: classes.dex */ final class CallEnqueueObservable extends AbstractC13163fSk> { private final Call originalCall; /* JADX INFO: Access modifiers changed from: package-private */ public CallEnqueueObservable(Call call) { this.originalCall = call; } @Override // o.AbstractC13163fSk public final void subscribeActual(InterfaceC13174fSv> interfaceC13174fSv) { Call clone = this.originalCall.clone(); CallCallback callCallback = new CallCallback(clone, interfaceC13174fSv); interfaceC13174fSv.onSubscribe(callCallback); if (callCallback.isDisposed()) { return; } clone.enqueue(callCallback); } /* loaded from: classes6.dex */ static final class CallCallback implements fSJ, Callback { private final Call call; private volatile boolean disposed; private final InterfaceC13174fSv> observer; boolean terminated = false; CallCallback(Call call, InterfaceC13174fSv> interfaceC13174fSv) { this.call = call; this.observer = interfaceC13174fSv; } @Override // retrofit2.Callback public final void onResponse(Call call, Response response) { if (this.disposed) { return; } try { this.observer.onNext(response); if (this.disposed) { return; } this.terminated = true; this.observer.onComplete(); } catch (Throwable th) { C13147fSI.c(th); if (this.terminated) { C13418fZu.c(th); return; } if (this.disposed) { return; } try { this.observer.onError(th); } catch (Throwable th2) { C13147fSI.c(th2); C13418fZu.c(new CompositeException(th, th2)); } } } @Override // retrofit2.Callback public final void onFailure(Call call, Throwable th) { if (call.isCanceled()) { return; } try { this.observer.onError(th); } catch (Throwable th2) { C13147fSI.c(th2); C13418fZu.c(new CompositeException(th, th2)); } } @Override // o.fSJ public final void dispose() { this.disposed = true; this.call.cancel(); } @Override // o.fSJ public final boolean isDisposed() { return this.disposed; } } }