Class SourceWrappers
- java.lang.Object
-
- io.servicetalk.http.router.jersey.internal.SourceWrappers
-
public final class SourceWrappers extends java.lang.Object
When request's contents are not buffered, Jersey's determines if the entity body input stream that backs a request can be closed by introspecting the return type of theMessageBodyReader
. If the return type is aCloseable
or aSource
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 theMessageBodyReader.readFrom(Class, Type, Annotation[], MediaType, MultivaluedMap, InputStream)
method.Since RS sources don't implement
Closeable
norSource
, 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.- See Also:
InboundMessageContext.readEntity(Class, Type, Annotation[], PropertiesDelegate)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SourceWrappers.PublisherSource<T>
APublisher
that is also aSource
.static class
SourceWrappers.SingleSource<T>
ASingle
that is also aSource
.
-