Skip to content

Commit 7925b52

Browse files
authored
Merge branch 'master' into chore-simplify-code
2 parents 8fa4d82 + 4423978 commit 7925b52

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/main/java/com/auth0/net/CustomRequest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ protected T parseResponse(Response response) throws Auth0Exception {
5757
throw createResponseException(response);
5858
}
5959

60-
String payload;
61-
try {
62-
payload = response.body().string();
60+
try (ResponseBody body = response.body()) {
61+
String payload = body.string();
6362
return mapper.readValue(payload, tType);
6463
} catch (IOException e) {
6564
throw new APIException("Failed to parse json body", response.code(), e);
@@ -98,8 +97,8 @@ protected RequestBody createBody() throws Auth0Exception {
9897

9998
protected Auth0Exception createResponseException(Response response) {
10099
String payload = null;
101-
try {
102-
payload = response.body().string();
100+
try (ResponseBody body = response.body()) {
101+
payload = body.string();
103102
MapType mapType = mapper.getTypeFactory().constructMapType(HashMap.class, String.class, Object.class);
104103
Map<String, Object> values = mapper.readValue(payload, mapType);
105104
return new APIException(values, response.code());

0 commit comments

Comments
 (0)