jimu-decompiled/sources/com/bumptech/glide/util/ExceptionCatchingInputStream.java
2025-05-13 19:24:51 +02:00

109 lines
2.5 KiB
Java

package com.bumptech.glide.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Queue;
/* loaded from: classes.dex */
public class ExceptionCatchingInputStream extends InputStream {
private static final Queue<ExceptionCatchingInputStream> c = Util.a(0);
private InputStream a;
private IOException b;
ExceptionCatchingInputStream() {
}
public static ExceptionCatchingInputStream b(InputStream inputStream) {
ExceptionCatchingInputStream poll;
synchronized (c) {
poll = c.poll();
}
if (poll == null) {
poll = new ExceptionCatchingInputStream();
}
poll.a(inputStream);
return poll;
}
void a(InputStream inputStream) {
this.a = inputStream;
}
@Override // java.io.InputStream
public int available() throws IOException {
return this.a.available();
}
@Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
this.a.close();
}
@Override // java.io.InputStream
public void mark(int i) {
this.a.mark(i);
}
@Override // java.io.InputStream
public boolean markSupported() {
return this.a.markSupported();
}
@Override // java.io.InputStream
public int read(byte[] bArr) {
try {
return this.a.read(bArr);
} catch (IOException e) {
this.b = e;
return -1;
}
}
@Override // java.io.InputStream
public synchronized void reset() throws IOException {
this.a.reset();
}
@Override // java.io.InputStream
public long skip(long j) {
try {
return this.a.skip(j);
} catch (IOException e) {
this.b = e;
return 0L;
}
}
public IOException a() {
return this.b;
}
@Override // java.io.InputStream
public int read(byte[] bArr, int i, int i2) {
try {
return this.a.read(bArr, i, i2);
} catch (IOException e) {
this.b = e;
return -1;
}
}
@Override // java.io.InputStream
public int read() {
try {
return this.a.read();
} catch (IOException e) {
this.b = e;
return -1;
}
}
public void b() {
this.b = null;
this.a = null;
synchronized (c) {
c.offer(this);
}
}
}