Skip to content

Commit

Permalink
Add documentation to clarify if ResponseBody.close() is necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
tejas-n committed May 24, 2020
1 parent f62316b commit c2500ca
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions retrofit/src/main/java/retrofit2/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,22 @@ public boolean isSuccessful() {
return rawResponse.isSuccessful();
}

/** The deserialized response body of a {@linkplain #isSuccessful() successful} response. */
/**
* The deserialized response body of a {@linkplain #isSuccessful() successful} response.
*
* <p>If the body is of type {@link ResponseBody}, calling {@link ResponseBody#close close} is
* unnecessary unless the Retrofit call was annotated with {@link retrofit2.http.Streaming @Streaming}
*/
public @Nullable T body() {
return body;
}

/** The raw response body of an {@linkplain #isSuccessful() unsuccessful} response. */
/**
* The raw response body of an {@linkplain #isSuccessful() unsuccessful} response.
*
* <p>Calling {@link ResponseBody#close close} on the response body is unnecessary since it is
* closed internally by Retrofit.
*/
public @Nullable ResponseBody errorBody() {
return errorBody;
}
Expand Down

0 comments on commit c2500ca

Please sign in to comment.