Class CoyoteInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
- Author:
- Remy Maucherat
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintprotected Objectclone()Prevent cloning the facade.voidclose()Close the stream Since we re-cycle, we can't allow the call to super.close() which would permanently disable us.booleanHas the end of this InputStream been reached?booleanisReady()Returnstrueif it is allowable to call aread()method.intread()intread(byte[] b) intread(byte[] b, int off, int len) intread(ByteBuffer b) Reads from the input stream into the given buffer.voidsetReadListener(ReadListener listener) Sets theReadListenerfor thisServletInputStreamand thereby switches to non-blocking IO.Methods inherited from class jakarta.servlet.ServletInputStream
readAllBytes, readLine, readNBytes, readNBytesMethods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, reset, skip, skipNBytes, transferTo
-
Field Details
-
sm
-
ib
-
-
Constructor Details
-
CoyoteInputStream
-
-
Method Details
-
clone
Prevent cloning the facade.- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
Description copied from class:jakarta.servlet.ServletInputStreamReads from the input stream into the given buffer.If the input stream is in non-blocking mode, before each invocation of this method
ServletInputStream.isReady()must be called and must returntrueor theReadListener.onDataAvailable()call back must indicate that data is available to read else anIllegalStateExceptionmust be thrown.Otherwise, if this method is called when
bufferhas no space remaining, the method returns0immediately andbufferis unchanged.If the input stream is in blocking mode and
bufferhas space remaining, this method blocks until at least one byte has been read, end of stream is reached or an exception is thrown.Returns the number of bytes read or
-1if the end of stream is reached without reading any data.When the method returns, and if data has been read, the buffer's position will be unchanged from the value when passed to this method and the limit will be the position incremented by the number of bytes read.
Subclasses are strongly encouraged to override this method and provide a more efficient implementation.
- Overrides:
readin classServletInputStream- Parameters:
b- The buffer into which the data is read.- Returns:
- The number of bytes read or
-1if the end of the stream has been reached. - Throws:
IOException- If data cannot be read for any reason other than the end of stream being reached, the input stream has been closed or if some other I/O error occurs.
-
close
Close the stream Since we re-cycle, we can't allow the call to super.close() which would permanently disable us.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
isFinished
public boolean isFinished()Description copied from class:jakarta.servlet.ServletInputStreamHas the end of this InputStream been reached?- Specified by:
isFinishedin classServletInputStream- Returns:
trueif all the data has been read from the stream, elsefalse
-
isReady
public boolean isReady()Description copied from class:jakarta.servlet.ServletInputStreamReturnstrueif it is allowable to call aread()method. In blocking mode, this method will always returntrue, but a subsequent call to aread()method may block awaiting data. In non-blocking mode this method may returnfalse, in which case it is illegal to call aread()method and anIllegalStateExceptionMUST be thrown. WhenReadListener.onDataAvailable()is called, a call to this method that returnedtrueis implicit.If this method returns
falseand aReadListenerhas been set viaServletInputStream.setReadListener(ReadListener), then the container will subsequently invokeReadListener.onDataAvailable()(orReadListener.onAllDataRead()) once data (or EOF) has become available. Other than the initial callReadListener.onDataAvailable()will only be called if and only if this method is called and returns false.- Specified by:
isReadyin classServletInputStream- Returns:
trueif data can be obtained without blocking, otherwise returnsfalse.
-
setReadListener
Description copied from class:jakarta.servlet.ServletInputStreamSets theReadListenerfor thisServletInputStreamand thereby switches to non-blocking IO. It is only valid to switch to non-blocking IO within async processing or HTTP upgrade processing.- Specified by:
setReadListenerin classServletInputStream- Parameters:
listener- The non-blocking IO read listener
-