Class CoyoteInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Author:
- Remy Maucherat
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
protected Object
clone()
Prevent cloning the facade.void
close()
Close the stream Since we re-cycle, we can't allow the call to super.close() which would permanently disable us.boolean
Has the end of this InputStream been reached?boolean
isReady()
Returnstrue
if it is allowable to call aread()
method.int
read()
int
read
(byte[] b) int
read
(byte[] b, int off, int len) int
read
(ByteBuffer b) Reads from the input stream into the given buffer.void
setReadListener
(ReadListener listener) Sets theReadListener
for thisServletInputStream
and thereby switches to non-blocking IO.Methods inherited from class jakarta.servlet.ServletInputStream
readAllBytes, readLine, readNBytes, readNBytes
Methods 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:
clone
in classObject
- Throws:
CloneNotSupportedException
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
Description copied from class:jakarta.servlet.ServletInputStream
Reads 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 returntrue
or theReadListener.onDataAvailable()
call back must indicate that data is available to read else anIllegalStateException
must be thrown.Otherwise, if this method is called when
buffer
has no space remaining, the method returns0
immediately andbuffer
is unchanged.If the input stream is in blocking mode and
buffer
has 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
-1
if 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:
read
in classServletInputStream
- Parameters:
b
- The buffer into which the data is read.- Returns:
- The number of bytes read or
-1
if 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
isFinished
public boolean isFinished()Description copied from class:jakarta.servlet.ServletInputStream
Has the end of this InputStream been reached?- Specified by:
isFinished
in classServletInputStream
- Returns:
true
if all the data has been read from the stream, elsefalse
-
isReady
public boolean isReady()Description copied from class:jakarta.servlet.ServletInputStream
Returnstrue
if 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 anIllegalStateException
MUST be thrown. WhenReadListener.onDataAvailable()
is called, a call to this method that returnedtrue
is implicit.If this method returns
false
and aReadListener
has 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:
isReady
in classServletInputStream
- Returns:
true
if data can be obtained without blocking, otherwise returnsfalse
.
-
setReadListener
Description copied from class:jakarta.servlet.ServletInputStream
Sets theReadListener
for thisServletInputStream
and 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:
setReadListener
in classServletInputStream
- Parameters:
listener
- The non-blocking IO read listener
-