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 voidprivate voidendRead()intGet number of milliseconds before aborting a read.intread()intread(byte[] buf) intread(byte[] buf, int off, int cnt) private InterruptedIOExceptionvoidsetTimeout(int millis) Set number of milliseconds before aborting a read.longskip(long cnt) Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, resetMethods 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:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classFilterInputStream- Throws:
IOException
-
beginRead
private void beginRead() -
endRead
private void endRead() -
readTimedOut
-