Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.61k stars 594 forks source link

HttpResponse not consume responseEntity if objectMapper throw exception #114

Closed ghost closed 5 years ago

ghost commented 9 years ago

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

ryber commented 5 years ago

Hello, this should be resolved or addressed in Unirest 2. Please see the upgrade guide for important changes.