Class EntityInputStream

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class EntityInputStream
    extends InputStream
    Entity input stream customized for entity message processing:
    • contains isEmpty() method.
    • close() method throws Jersey-specific runtime exception in case of an IO error.
    Author:
    Marek Potociar
    • Constructor Detail

      • EntityInputStream

        public EntityInputStream​(InputStream input)
        Extension constructor.
        Parameters:
        input - underlying wrapped input stream.
    • Method Detail

      • create

        public static EntityInputStream create​(InputStream inputStream)
        Create an entity input stream instance wrapping the original input stream.

        In case the original entity stream is already of type EntityInputStream, the stream is returned without wrapping.

        Parameters:
        inputStream - input stream.
        Returns:
        entity input stream.
      • mark

        public void mark​(int readLimit)
        Overrides:
        mark in class InputStream
      • reset

        public void reset()

        The method is customized to not throw an IOException if the reset operation fails. Instead, a runtime ProcessingException is thrown.

        Overrides:
        reset in class InputStream
        Throws:
        jakarta.ws.rs.ProcessingException - in case the reset operation on the underlying entity input stream failed.
      • close

        public void close()
                   throws jakarta.ws.rs.ProcessingException

        The method is customized to not throw an IOException if the close operation fails. Instead, a warning message is logged.

        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Overrides:
        close in class InputStream
        Throws:
        jakarta.ws.rs.ProcessingException
      • isEmpty

        public boolean isEmpty()
        Check if the underlying entity stream is empty.

        Note that the operation may need to block until a first byte (or EOF) is available in the stream.

        Returns:
        true if the entity stream is empty, false otherwise.
      • ensureNotClosed

        public void ensureNotClosed()
                             throws IllegalStateException
        Check that the entity input stream has not been closed yet.
        Throws:
        IllegalStateException - in case the entity input stream has been closed.
      • isClosed

        public boolean isClosed()
        Get the closed status of this input stream.
        Returns:
        true if the stream has been closed, false otherwise.
      • getWrappedStream

        public final InputStream getWrappedStream()
        Get the wrapped input stream instance.
        Returns:
        wrapped input stream instance.
      • setWrappedStream

        public final void setWrappedStream​(InputStream wrapped)
        Set the wrapped input stream instance.
        Parameters:
        wrapped - new input stream instance to be wrapped.