Class DefensiveDrainable
java.lang.Object
java.io.InputStream
io.deephaven.extensions.barrage.util.DefensiveDrainable
- All Implemented Interfaces:
io.grpc.Drainable
,Closeable
,AutoCloseable
- Direct Known Subclasses:
ChunkInputStreamGenerator.DrainableColumn
,ConsecutiveDrainableStreams
,DrainableByteArrayInputStream
A defensive
Drainable
implementation that supports the non-read methods of InputStream
. Callers
should use Drainable.drainTo(OutputStream)
when applicable. If handing off to external code that needs a real
InputStream
, use capture()
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
A defensive drainable needs to override available.final InputStream
capture()
Capturesthis
drainable as a realInputStream
.final int
read()
final int
read
(@org.jetbrains.annotations.NotNull byte[] b) final int
read
(@org.jetbrains.annotations.NotNull byte[] b, int off, int len) final long
skip
(long n) Methods inherited from class java.io.InputStream
close, mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.grpc.Drainable
drainTo
-
Constructor Details
-
DefensiveDrainable
public DefensiveDrainable()
-
-
Method Details
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
public final int read(@NotNull @org.jetbrains.annotations.NotNull byte[] b, int off, int len) throws IOException - Overrides:
read
in classInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
available
A defensive drainable needs to override available. As opposed to the genericInputStream
, this method must return the exact amount available.- Overrides:
available
in classInputStream
- Returns:
- the exact amount available
- Throws:
IOException
- if an I/O exception occurs
-
capture
Capturesthis
drainable as a realInputStream
.- Returns:
- a real input stream
-