package j0.l.a; import j0.g; import j0.o.l; import java.util.Arrays; import rx.Observable; import rx.Subscriber; import rx.exceptions.CompositeException; /* compiled from: OnSubscribeDoOnEach */ public class k implements Observable.a { public final g i; public final Observable j; /* compiled from: OnSubscribeDoOnEach */ public static final class a extends Subscriber { public final Subscriber i; public final g j; public boolean k; public a(Subscriber subscriber, g gVar) { super(subscriber); this.i = subscriber; this.j = gVar; } @Override // j0.g public void onCompleted() { if (!this.k) { try { this.j.onCompleted(); this.k = true; this.i.onCompleted(); } catch (Throwable th) { c.q.a.k.a.a0(th); onError(th); } } } @Override // j0.g public void onError(Throwable th) { if (this.k) { l.b(th); return; } this.k = true; try { this.j.onError(th); this.i.onError(th); } catch (Throwable th2) { c.q.a.k.a.a0(th2); this.i.onError(new CompositeException(Arrays.asList(th, th2))); } } @Override // j0.g public void onNext(T t) { if (!this.k) { try { this.j.onNext(t); this.i.onNext(t); } catch (Throwable th) { c.q.a.k.a.b0(th, this, t); } } } } public k(Observable observable, g gVar) { this.j = observable; this.i = gVar; } @Override // rx.functions.Action1 public void call(Object obj) { this.j.i0(new a((Subscriber) obj, this.i)); } }