Skip to content

Commit

Permalink
#504 mailgun mailer: close response using try with resource
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Sep 13, 2018
1 parent 94919e0 commit 108f448
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/java/alfio/manager/system/MailgunMailer.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,10 @@ public void send(Event event, String to, List<String> cc, String subject, String
.header("Authorization", Credentials.basic("api", apiKey))
.post(formBody).build();

Response resp = client.newCall(request).execute();
if (!resp.isSuccessful()) {
log.warn("sending email was not successful:" + resp);
} else {
//close response body, in order to prevent leaks
resp.body().close();
try(Response resp = client.newCall(request).execute()) {
if (!resp.isSuccessful()) {
log.warn("sending email was not successful:" + resp);
}
}
} catch (IOException e) {
log.warn("error while sending email", e);
Expand Down

0 comments on commit 108f448

Please sign in to comment.