Top Description Inners Fields Constructors Methods
io.undertow.servlet.spec

public Class UpgradeServletOutputStream

extends ServletOutputStream
Class Inheritance
Imports
io.undertow.servlet.UndertowServletMessages, org.xnio.ChannelListener, .IoUtils, org.xnio.channels.Channels, .StreamSinkChannel, jakarta.servlet.ServletOutputStream, .WriteListener, java.io.IOException, java.nio.ByteBuffer, java.util.concurrent.Executor

Output stream used for upgraded requests. This is different to ServletOutputStreamImpl as it does no buffering, and it not tied to an exchange.
Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private ByteBuffer
buffer

The buffer that is in the process of being written out

private final StreamSinkChannel
private static final int
private static final int
private static final int
FLAG_READY

If this stream is ready for a write

private final Executor
private WriteListener
private int

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with this stream.

pack-priv void
public void
flush()

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Flushes this output stream and forces any buffered output bytes to be written out.

public boolean
isReady()

Implements abstract jakarta.servlet.ServletOutputStream.isReady.

Returns true if data can be written without blocking else returns false.

public void
setWriteListener(final WriteListener
the WriteListener that should be notified when it's possible to write
writeListener
)

Implements abstract jakarta.servlet.ServletOutputStream.setWriteListener.

Instructs the ServletOutputStream to invoke the provided WriteListener when it is possible to write

public void
write(final byte[]
the data.
b
)

Overrides java.io.OutputStream.write.

Writes b.length bytes from the specified byte array to this output stream.

public void
write(final byte[]
the data.
b
,
final int
the start offset in the data.
off
,
final int
the number of bytes to write.
len
)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

public void
write(final int
the byte.
b
)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.

Inherited from jakarta.servlet.ServletOutputStream:
printprintprintprintprintprintprintprintlnprintlnprintlnprintlnprintlnprintlnprintlnprintln

Field Detail

bufferback to summary
private ByteBuffer buffer

The buffer that is in the process of being written out

channelback to summary
private final StreamSinkChannel channel
FLAG_CLOSEDback to summary
private static final int FLAG_CLOSED
FLAG_DELEGATE_SHUTDOWNback to summary
private static final int FLAG_DELEGATE_SHUTDOWN
FLAG_READYback to summary
private static final int FLAG_READY

If this stream is ready for a write

ioExecutorback to summary
private final Executor ioExecutor
listenerback to summary
private WriteListener listener
stateback to summary
private int state

Constructor Detail

UpgradeServletOutputStreamback to summary
protected UpgradeServletOutputStream(final StreamSinkChannel channel, Executor ioExecutor)

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.OutputStream.close.

Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
closeBlockingback to summary
pack-priv void closeBlocking() throws IOException
flushback to summary
public void flush() throws IOException

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Doc from java.io.OutputStream.flush.

Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
isReadyback to summary
public boolean isReady()

Implements abstract jakarta.servlet.ServletOutputStream.isReady.

Doc from jakarta.servlet.ServletOutputStream.isReady.

Returns true if data can be written without blocking else returns false.

If this method returns false and a WriteListener has been set with setWriteListener(WriteListener), then container will subsequently invoke WriteListener#onWritePossible() once a write operation becomes possible without blocking. Other than the initial call, WriteListener#onWritePossible() will only be called if and only if this method is called and returns false.

Returns:boolean

true if data can be written without blocking, otherwise returns false.

Annotations
@Override
setWriteListenerback to summary
public void setWriteListener(final WriteListener writeListener)

Implements abstract jakarta.servlet.ServletOutputStream.setWriteListener.

Doc from jakarta.servlet.ServletOutputStream.setWriteListener.

Instructs the ServletOutputStream to invoke the provided WriteListener when it is possible to write

Parameters
writeListener:WriteListener

the WriteListener that should be notified when it's possible to write

Annotations
@Override
writeback to summary
public void write(final byte[] b) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes b.length bytes from the specified byte array to this output stream. The general contract for write(b) is that it should have exactly the same effect as the call write(b, 0, b.length).

Parameters
b:byte[]

the data.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(final byte[] b, final int off, final int len) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Parameters
b:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.
writeback to summary
public void write(final int b) throws IOException

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters
b:int

the byte.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
io.undertow.servlet.spec back to summary

private Class UpgradeServletOutputStream.WriteChannelListener

extends Object
implements ChannelListener<StreamSinkChannel>
Class Inheritance
  • java.lang.Object
  • io.undertow.servlet.spec.UpgradeServletOutputStream.WriteChannelListener
All Implemented Interfaces
org.xnio.ChannelListener, java.util.EventListener

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
handleError(final StreamSinkChannel channel, final IOException e)

public void
handleEvent(final StreamSinkChannel
the channel event
channel
)

Implements org.xnio.ChannelListener.handleEvent.

Handle the event on this channel.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

WriteChannelListenerback to summary
private WriteChannelListener()

Method Detail

handleErrorback to summary
private void handleError(final StreamSinkChannel channel, final IOException e)
handleEventback to summary
public void handleEvent(final StreamSinkChannel channel)

Implements org.xnio.ChannelListener.handleEvent.

Doc from org.xnio.ChannelListener.handleEvent.

Handle the event on this channel.

Parameters
channel:StreamSinkChannel

the channel event

Annotations
@Override