From bedd4eaf845ce6a6f23eb6598771672978fd568c Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 26 Nov 2015 14:55:24 +0900 Subject: [PATCH] HttpPluginServlet: Use try-with-resource in readWholeEntry This was already done on master/stable-2.12 in change I94f481a33 which updated several places to use try-with-resource. Backporting this specific one so it's easier to apply Luca's fix for "short read of block" without conflict. Change-Id: I1ec84f15b09b860c3f416a5000ad4e950a2a3977 --- .../com/google/gerrit/httpd/plugins/HttpPluginServlet.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java index 64b754d164..73fbb3c24e 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java @@ -649,11 +649,8 @@ class HttpPluginServlet extends HttpServlet private static byte[] readWholeEntry(PluginContentScanner scanner, PluginEntry entry) throws IOException { byte[] data = new byte[entry.getSize().get().intValue()]; - InputStream in = scanner.getInputStream(entry); - try { + try (InputStream in = scanner.getInputStream(entry)) { IO.readFully(in, data, 0, data.length); - } finally { - in.close(); } return data; }