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 3e6572f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 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,23 @@ 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 3e6572f

Please sign in to comment.