Package com.bumptech.glide.util
Class ExceptionPassthroughInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.bumptech.glide.util.ExceptionPassthroughInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public final class ExceptionPassthroughInputStream extends java.io.InputStreamAnInputStreamthat catches, stores and rethrowsIOExceptions during read and skip calls. This allows users of this API to handle the exception at a higher level if the exception is swallowed by some intermediate library. This class is a workaround for a framework issue where exceptions during reads while decoding bitmaps inBitmapFactorycan return partially decoded bitmaps.Unlike the deprecated
ExceptionCatchingInputStream, this class will both store and re-throw any IOExceptions. Rethrowing works around bugs in wrapping streams that may not fully obey the stream contract. This is really only useful if some middle layer is going to catch the exception (like BitmapFactory) but we want to propagate the exception instead.See https://github.com/bumptech/glide/issues/126 and #4438.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()java.io.IOExceptiongetException()voidmark(int readLimit)booleanmarkSupported()static ExceptionPassthroughInputStreamobtain(java.io.InputStream toWrap)intread()intread(byte[] buffer)intread(byte[] buffer, int byteOffset, int byteCount)voidrelease()voidreset()longskip(long byteCount)
-
-
-
Method Detail
-
obtain
@NonNull public static ExceptionPassthroughInputStream obtain(@NonNull java.io.InputStream toWrap)
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
mark
public void mark(int readLimit)
- Overrides:
markin classjava.io.InputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.InputStream
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] buffer) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] buffer, int byteOffset, int byteCount) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
reset
public void reset() throws java.io.IOException- Overrides:
resetin classjava.io.InputStream- Throws:
java.io.IOException
-
skip
public long skip(long byteCount) throws java.io.IOException- Overrides:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
getException
@Nullable public java.io.IOException getException()
-
release
public void release()
-
-