Package org.eclipse.jgit.util.io
Class TimeoutInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.eclipse.jgit.util.io.TimeoutInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
InputStream with a configurable timeout.
-
Field Summary
FieldsFields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
ConstructorsConstructorDescriptionTimeoutInputStream
(InputStream src, InterruptTimer timer) Wrap an input stream with a timeout on all read operations. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
private void
endRead()
int
Get number of milliseconds before aborting a read.int
read()
int
read
(byte[] buf) int
read
(byte[] buf, int off, int cnt) private InterruptedIOException
void
setTimeout
(int millis) Set number of milliseconds before aborting a read.long
skip
(long cnt) Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, reset
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
myTimer
-
timeout
private int timeout
-
-
Constructor Details
-
TimeoutInputStream
Wrap an input stream with a timeout on all read operations.- Parameters:
src
- base input stream (to read from). The stream must be interruptible (most socket streams are).timer
- timer to manage the timeouts during reads.
-
-
Method Details
-
getTimeout
public int getTimeout()Get number of milliseconds before aborting a read.- Returns:
- number of milliseconds before aborting a read.
-
setTimeout
public void setTimeout(int millis) Set number of milliseconds before aborting a read.- Parameters:
millis
- number of milliseconds before aborting a read. Must be > 0.
-
read
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classFilterInputStream
- Throws:
IOException
-
beginRead
private void beginRead() -
endRead
private void endRead() -
readTimedOut
-