From cd63bcaff5add189a214e0ebd9218892c2a0cac1 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 27 Aug 2015 14:24:05 +0900 Subject: [PATCH] Use try-with-resource when opening stream Change-Id: Ie83c3f5ef629b49bec5984c1c7f47433673fb4df --- .../com/google/gerrit/httpd/restapi/RestApiServlet.java | 8 ++++---- plugins/cookbook-plugin | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/restapi/RestApiServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/restapi/RestApiServlet.java index 44bf7aa6ba..2f2575d36d 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/restapi/RestApiServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/restapi/RestApiServlet.java @@ -1062,10 +1062,10 @@ public class RestApiServlet extends HttpServlet { int maxSize = base64MaxSize(bin.getContentLength()); int estSize = Math.min(base64MaxSize(HEAP_EST_SIZE), maxSize); TemporaryBuffer.Heap buf = heap(estSize, maxSize); - OutputStream encoded = BaseEncoding.base64().encodingStream( - new OutputStreamWriter(buf, ISO_8859_1)); - bin.writeTo(encoded); - encoded.close(); + try (OutputStream encoded = BaseEncoding.base64().encodingStream( + new OutputStreamWriter(buf, ISO_8859_1))) { + bin.writeTo(encoded); + } return asBinaryResult(buf); } diff --git a/plugins/cookbook-plugin b/plugins/cookbook-plugin index 730613516a..b9d3ca8a65 160000 --- a/plugins/cookbook-plugin +++ b/plugins/cookbook-plugin @@ -1 +1 @@ -Subproject commit 730613516a733fa33f684cbe03fe22ecf811216e +Subproject commit b9d3ca8a65030071e28be19296ba867ab424fbbf