joshgontijo / rest-client

MIT License
21 stars 5 forks source link

HttpResponse not consume responseEntity if objectMapper throw exception #59

Closed joshgontijo closed 7 years ago

joshgontijo commented 7 years ago

From #114

HttpResponse.java line 101, 103,


} else if (objectMapper != null) {
this.body = objectMapper.readValue(new String(rawBody, charset), responseClass);
} else {
throw new Exception("Only String, JsonNode and InputStream are supported, or an ObjectMapper implementation is required.");
}

if the objectmapper throw exception or new Exception is throw, the exception is catcher and a new RuntimeException will be throw out.

then the line 110, EntityUtils.consume(responseEntity); will never be executed.

i believe, it should be clean up, before throw the RuntimeException

joshgontijo commented 7 years ago

Added EntityUtils.consumeQuietly(responseEntity); to catch block