public final class SourceWrappers
extends java.lang.Object
MessageBodyReader
. If the return type is
a Closeable
or a Source
then it doesn't close it, otherwise it closes it.
We have MessageBodyReader
s that deliver content as RS sources: in that case we do not want Jersey to close
the backing input stream because the content has not been consumed yet when exiting
the MessageBodyReader.readFrom(Class, Type, Annotation[], MediaType, MultivaluedMap, InputStream)
method.
Since RS sources don't implement Closeable
nor Source
, this class provides wrappers that implement
the latter, allowing us to prevent an untimely closure of the entity input stream.
Note that this is only necessary when a user-provided entity input stream is used, which can only happen when
a filter or interceptor has replaced the one we've put in place at request creation time.
Indeed, the close()
method of the entity stream we initially provide (BufferPublisherInputStream
)
is a no-op so it doesn't matter if it gets called.
InboundMessageContext.readEntity(Class, Type, Annotation[], PropertiesDelegate)
Modifier and Type | Class and Description |
---|---|
static class |
SourceWrappers.PublisherSource<T>
A
Publisher that is also a Source . |
static class |
SourceWrappers.SingleSource<T>
A
Single that is also a Source . |