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 <[email protected]>


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 <[email protected]>
Authored: Wed Apr 26 22:23:30 2017 -0400
Committer: joewitt <[email protected]>
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) {

Reply via email to