Class OpsViewManager.CloseableClientResponse
java.lang.Object
ecmwf.common.opsview.OpsViewManager.CloseableClientResponse
- All Implemented Interfaces:
Closeable, AutoCloseable
- Enclosing class:
OpsViewManager
A wrapper around
ClientResponse that implements Closeable.
This allows the use of try-with-resources to automatically release underlying HTTP/SSL connections by calling
ClientResponse.consumeContent() when done.
-
Constructor Summary
ConstructorsConstructorDescriptionCloseableClientResponse(org.apache.wink.client.ClientResponse response) Constructs a new CloseableClientResponse wrapping the given ClientResponse. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the response by consuming its content.<T> TReads and returns the entity from the response.Returns the HTTP status message of the response.intReturns the HTTP status code of the response.
-
Constructor Details
-
CloseableClientResponse
public CloseableClientResponse(org.apache.wink.client.ClientResponse response) Constructs a new CloseableClientResponse wrapping the given ClientResponse.- Parameters:
response- the ClientResponse to wrap; must not be null
-
-
Method Details
-
getStatusCode
public int getStatusCode()Returns the HTTP status code of the response.- Returns:
- the HTTP status code
-
getMessage
Returns the HTTP status message of the response.- Returns:
- the status message
-
getEntity
Reads and returns the entity from the response.Note that calling this method will fully read the entity into memory.
- Type Parameters:
T- the type of the entity- Parameters:
t- the class of the entity- Returns:
- the entity deserialized as the given class
-
close
public void close()Closes the response by consuming its content.This ensures that the underlying HTTP/SSL connection is released and prevents potential connection leaks.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if an I/O error occurs while consuming the content
-