Class CoyoteInputStream
- All Implemented Interfaces:
- Closeable,- AutoCloseable
- Author:
- Remy Maucherat
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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.ServletInputStreamreadAllBytes, readLine, readNBytes, readNBytesMethods inherited from class java.io.InputStreammark, markSupported, nullInputStream, reset, skip, skipNBytes, transferTo
- 
Field Details- 
sm
- 
ib
 
- 
- 
Constructor Details- 
CoyoteInputStream
 
- 
- 
Method Details- 
clonePrevent cloning the facade.- Overrides:
- clonein class- Object
- Throws:
- CloneNotSupportedException
 
- 
read- Specified by:
- readin class- InputStream
- Throws:
- IOException
 
- 
available- Overrides:
- availablein class- InputStream
- Throws:
- IOException
 
- 
read- Overrides:
- readin class- InputStream
- Throws:
- IOException
 
- 
read- Overrides:
- readin class- InputStream
- Throws:
- IOException
 
- 
readDescription 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 class- ServletInputStream
- 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.
 
- 
closeClose the stream Since we re-cycle, we can't allow the call to super.close() which would permanently disable us.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- InputStream
- Throws:
- IOException
 
- 
isFinishedpublic boolean isFinished()Description copied from class:jakarta.servlet.ServletInputStreamHas the end of this InputStream been reached?- Specified by:
- isFinishedin class- ServletInputStream
- Returns:
- trueif all the data has been read from the stream, else- false
 
- 
isReadypublic 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 class- ServletInputStream
- Returns:
- trueif data can be obtained without blocking, otherwise returns- false.
 
- 
setReadListenerDescription 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 class- ServletInputStream
- Parameters:
- listener- The non-blocking IO read listener
 
 
-