From 15db2c1a8a66c89692ce4392d5388269e82cee2c Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 10 Nov 2016 18:29:20 +0100 Subject: [PATCH] SONAR-8351 fix resource leak when sending HTTP request --- .../task/projectanalysis/webhook/WebhookCallerImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookCallerImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookCallerImpl.java index 60a84bd7330..58fbf1e257c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookCallerImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/webhook/WebhookCallerImpl.java @@ -56,8 +56,7 @@ public class WebhookCallerImpl implements WebhookCaller { .setAt(startedAt) .setPayload(payload) .setWebhook(webhook); - try { - Response response = okHttpClient.newCall(request.build()).execute(); + try (Response response = okHttpClient.newCall(request.build()).execute()) { builder.setHttpStatus(response.code()); builder.setDurationInMs((int)(system.now() - startedAt)); } catch (IOException e) { -- 2.39.5