Skip to content

Commit

Permalink
Introduce Response.isClosed() method with default impl.
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas NESMON (NicoNes) <[email protected]>
  • Loading branch information
NicoNes authored and mkarg committed Aug 24, 2021
1 parent 82ed589 commit 4ecc44c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions jaxrs-api/src/main/java/jakarta/ws/rs/core/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,22 @@ public MultivaluedMap<String, Object> getHeaders() {
*/
public abstract String getHeaderString(String name);

/**
* Check if the response is closed. The method returns {@code true} if the response is closed,
* returns {@code false} otherwise.
*
* @return {@code true} if the response has been {@link #close() closed}, {@code false} otherwise.
* @since 3.1
*/
public boolean isClosed() {
try {
hasEntity();
return false;
} catch (IllegalStateException ignored) {
return true;
}
}

/**
* Create a new ResponseBuilder by performing a shallow copy of an existing Response.
* <p>
Expand Down

0 comments on commit 4ecc44c

Please sign in to comment.