discord-jadx/app/src/main/java/g0/c.java

115 lines
2.8 KiB
Java

package g0;
import c.d.b.a.a;
import d0.z.d.m;
import java.io.IOException;
/* compiled from: AsyncTimeout.kt */
public final class c implements v {
public final /* synthetic */ b i;
public final /* synthetic */ v j;
public c(b bVar, v vVar) {
this.i = bVar;
this.j = vVar;
}
@Override // g0.v, java.io.Closeable, java.lang.AutoCloseable
public void close() {
b bVar = this.i;
bVar.i();
try {
this.j.close();
if (bVar.j()) {
throw bVar.k(null);
}
} catch (IOException e) {
if (!bVar.j()) {
throw e;
}
throw bVar.k(e);
} finally {
bVar.j();
}
}
@Override // g0.v, java.io.Flushable
public void flush() {
b bVar = this.i;
bVar.i();
try {
this.j.flush();
if (bVar.j()) {
throw bVar.k(null);
}
} catch (IOException e) {
if (!bVar.j()) {
throw e;
}
throw bVar.k(e);
} finally {
bVar.j();
}
}
@Override // g0.v
public y timeout() {
return this.i;
}
@Override // java.lang.Object
public String toString() {
StringBuilder L = a.L("AsyncTimeout.sink(");
L.append(this.j);
L.append(')');
return L.toString();
}
@Override // g0.v
public void write(e eVar, long j) {
m.checkParameterIsNotNull(eVar, "source");
c.q.a.k.a.l(eVar.j, 0, j);
while (true) {
long j2 = 0;
if (j > 0) {
s sVar = eVar.i;
if (sVar == null) {
m.throwNpe();
}
while (true) {
if (j2 >= ((long) 65536)) {
break;
}
j2 += (long) (sVar.f2787c - sVar.b);
if (j2 >= j) {
j2 = j;
break;
}
sVar = sVar.f;
if (sVar == null) {
m.throwNpe();
}
}
b bVar = this.i;
bVar.i();
try {
this.j.write(eVar, j2);
if (!bVar.j()) {
j -= j2;
} else {
throw bVar.k(null);
}
} catch (IOException e) {
if (!bVar.j()) {
throw e;
}
throw bVar.k(e);
} finally {
bVar.j();
}
} else {
return;
}
}
}
}