RestApiServlet: Flush pending padding as well

This issue was found by scan.coverity.com (CID 19911)
which is a static code analysis tool, free for open source
code. Originally it was classified as a resource leak, but
this is a miss classification as the auto closing of the
OutputStream will flush any pending padding.

Change-Id: I4dc2d1cd9f52740490fda7c37e98b115fa59ec3a
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 5055d47..5a0956d 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
@@ -767,10 +767,11 @@
       b64 = new BinaryResult() {
         @Override
         public void writeTo(OutputStream out) throws IOException {
-          OutputStream e = BaseEncoding.base64().encodingStream(
-              new OutputStreamWriter(out, ISO_8859_1));
-          src.writeTo(e);
-          e.flush();
+          try (OutputStreamWriter w = new OutputStreamWriter(out, ISO_8859_1);
+              OutputStream e = BaseEncoding.base64().encodingStream(w)) {
+            src.writeTo(e);
+            e.flush();
+          }
         }
       };
     }