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
This commit is contained in:
Stefan Beller 2015-02-03 09:03:55 -08:00 committed by David Pursehouse
parent e0ad57751b
commit 373794473a

View File

@ -740,10 +740,11 @@ public class RestApiServlet extends HttpServlet {
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();
}
}
};
}