Class ClientResponse
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
FinalizedClientResponse
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jboss.resteasy.specimpl.AbstractBuiltResponse
AbstractBuiltResponse.InputStreamWrapper<T extends BuiltResponse>Nested classes/interfaces inherited from class jakarta.ws.rs.core.Response
Response.ResponseBuilder, Response.Status, Response.StatusType -
Field Summary
FieldsFields inherited from class org.jboss.resteasy.specimpl.AbstractBuiltResponse
annotations, bufferedEntity, entity, entityClass, genericType, is, isClosed, metadata, processor, reason, status, streamFullyRead, streamRead -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedClientResponse(ClientConfiguration configuration) Deprecated.protectedClientResponse(ClientConfiguration configuration, RESTEasyTracingLogger tracingLogger) -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanBuffer the message entity data.voidclose()Close the underlying message entity input stream (if available and open) as well as releases any other resources associated with the response (e.g.Get the message entity Java instance.Class<?>protected InputStreamprotected HeaderValueProcessorbooleanCheck if there is an entity available in the response.voidIn case of an InputStream or Reader and a invocation that returns no Response object, we need to make sure the GC does not close the returned InputStream or Readerprotected <T> ObjectreadFrom(Class<T> type, Type genericType, MediaType media, Annotation[] annotations) voidsetClientConfiguration(ClientConfiguration configuration) voidsetHeaders(MultivaluedMap<String, String> headers) protected abstract voidvoidsetProperties(Map<String, Object> properties) Methods inherited from class org.jboss.resteasy.specimpl.BuiltResponse
getInputStream, readEntity, releaseConnection, releaseConnectionMethods inherited from class org.jboss.resteasy.specimpl.AbstractBuiltResponse
addMethodAnnotations, getAllowedMethods, getAnnotations, getCookies, getDate, getEntityTag, getGenericType, getHeaderString, getLanguage, getLastModified, getLength, getLink, getLinkBuilder, getLinks, getLocation, getMediaType, getMetadata, getReasonPhrase, getStatus, getStatusInfo, getStringHeaders, hasLink, isClosed, readEntity, readEntity, readEntity, readEntity, resetEntity, setAnnotations, setEntity, setEntityClass, setGenericType, setMetadata, setReasonPhrase, setStatus, setStreamFullyRead, setStreamRead, toHeaderStringMethods inherited from class jakarta.ws.rs.core.Response
accepted, accepted, created, fromResponse, getHeaders, noContent, notAcceptable, notModified, notModified, notModified, ok, ok, ok, ok, ok, seeOther, serverError, status, status, status, status, temporaryRedirect
-
Field Details
-
properties
-
configuration
-
tracingLogger
-
-
Constructor Details
-
ClientResponse
Deprecated. -
ClientResponse
-
-
Method Details
-
setHeaders
-
setProperties
-
getProperties
-
setClientConfiguration
-
getEntity
Description copied from class:ResponseGet the message entity Java instance. Returnsnullif the message does not contain an entity body.If the entity is represented by an un-consumed
input streamthe method will return the input stream.- Overrides:
getEntityin classAbstractBuiltResponse- Returns:
- the message entity or
nullif message does not contain an entity body (i.e. whenResponse.hasEntity()returnsfalse).
-
getEntityClass
- Overrides:
getEntityClassin classAbstractBuiltResponse
-
hasEntity
public boolean hasEntity()Description copied from class:ResponseCheck if there is an entity available in the response. The method returnstrueif the entity is present, returnsfalseotherwise.Note that the method may return
truealso for response messages with a zero-length content, in case the"Content-Length"and"Content-Type"headers are specified in the message. In such case, an attempt to read the entity using one of thereadEntity(...)methods will return a corresponding instance representing a zero-length entity for a given Java type or produce aProcessingExceptionin case no such instance is available for the Java type.- Overrides:
hasEntityin classAbstractBuiltResponse- Returns:
trueif there is an entity present in the message,falseotherwise.
-
noReleaseConnection
public void noReleaseConnection()In case of an InputStream or Reader and a invocation that returns no Response object, we need to make sure the GC does not close the returned InputStream or Reader -
close
public void close()Description copied from class:ResponseClose the underlying message entity input stream (if available and open) as well as releases any other resources associated with the response (e.g.buffered message entity data).This operation is idempotent, i.e. it can be invoked multiple times with the same effect which also means that calling the
close()method on an already closed message instance is legal and has no further effect.The
close()method should be invoked on all instances that contain an un-consumed entity input stream to ensure the resources associated with the instance are properly cleaned-up and prevent potential memory leaks. This is typical for client-side scenarios where application layer code processes only the response headers and ignores the response entity.Any attempts to manipulate (read, get, buffer) a message entity on a closed response will result in an
IllegalStateExceptionbeing thrown.- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classAbstractBuiltResponse
-
getHeaderValueProcessor
- Overrides:
getHeaderValueProcessorin classAbstractBuiltResponse
-
getEntityStream
- Overrides:
getEntityStreamin classBuiltResponse
-
setInputStream
- Overrides:
setInputStreamin classBuiltResponse
-
readFrom
protected <T> Object readFrom(Class<T> type, Type genericType, MediaType media, Annotation[] annotations) - Overrides:
readFromin classBuiltResponse
-
bufferEntity
public boolean bufferEntity()Description copied from class:ResponseBuffer the message entity data.In case the message entity is backed by an unconsumed entity input stream, all the bytes of the original entity input stream are read and stored in a local buffer. The original entity input stream is consumed and automatically closed as part of the operation and the method returns
true.In case the response entity instance is not backed by an unconsumed input stream an invocation of
bufferEntitymethod is ignored and the method returnsfalse.This operation is idempotent, i.e. it can be invoked multiple times with the same effect which also means that calling the
bufferEntity()method on an already buffered (and thus closed) message instance is legal and has no further effect. Also, the result returned by thebufferEntity()method is consistent across all invocations of the method on the sameResponseinstance.Buffering the message entity data allows for multiple invocations of
readEntity(...)methods on the response instance. Note however, that once the response instance itself isclosed, the implementations are expected to release the buffered message entity data too. Therefore any subsequent attempts to read a message entity stream on such closed response will result in anIllegalStateExceptionbeing thrown.- Overrides:
bufferEntityin classBuiltResponse- Returns:
trueif the message entity input stream was available and was buffered successfully, returnsfalseif the entity stream was not available.
-
abortIfClosed
public void abortIfClosed()- Overrides:
abortIfClosedin classAbstractBuiltResponse
-