You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by jo...@apache.org on 2017/04/27 19:05:02 UTC

nifi git commit: NIFI-3633 This closes #1705. Adding a try with resources so the OkHttp response is properly closed

Repository: nifi
Updated Branches:
  refs/heads/master 726d15d1f -> 49a9bc88c


NIFI-3633 This closes #1705. Adding a try with resources so the OkHttp response is properly closed

Signed-off-by: joewitt <jo...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/49a9bc88
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/49a9bc88
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/49a9bc88

Branch: refs/heads/master
Commit: 49a9bc88c66d84c30d7ed2f213b35d2835ffc3e5
Parents: 726d15d
Author: Joe Percivall <JP...@apache.org>
Authored: Wed Apr 26 22:23:30 2017 -0400
Committer: joewitt <jo...@apache.org>
Committed: Thu Apr 27 15:04:51 2017 -0400

----------------------------------------------------------------------
 .../notification/http/HttpNotificationService.java       | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/49a9bc88/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/notification/http/HttpNotificationService.java
----------------------------------------------------------------------
diff --git a/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/notification/http/HttpNotificationService.java b/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/notification/http/HttpNotificationService.java
index 22d8bf1..0e9a004 100644
--- a/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/notification/http/HttpNotificationService.java
+++ b/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/notification/http/HttpNotificationService.java
@@ -226,12 +226,13 @@ public class HttpNotificationService extends AbstractNotificationService {
             final OkHttpClient httpClient = httpClientReference.get();
 
             final Call call = httpClient.newCall(request);
-            final Response response = call.execute();
+             try (final Response response = call.execute()) {
 
-            if (!response.isSuccessful()) {
-                throw new NotificationFailedException("Failed to send Http Notification. Received an unsuccessful status code response '" + response.code() +"'. The message was '" +
-                        response.message() + "'");
-            }
+                 if (!response.isSuccessful()) {
+                     throw new NotificationFailedException("Failed to send Http Notification. Received an unsuccessful status code response '" + response.code() + "'. The message was '" +
+                             response.message() + "'");
+                 }
+             }
         } catch (NotificationFailedException e){
             throw e;
         } catch (Exception e) {