RestApiServlet: Leave OutputStream open when flushing base64 padding

Some Java servlet containers fail if the response's OutputStream is
closed twice by the application. This appears to contradict standard
behavior in Java where most streams gracefully ignore extra close.
Unfortunately the container is required to power gerrit-review and
as such Gerrit needs to try to tolerate its behavior.

Wrap the supplied OutputStream delegating all calls except for
close(). No-op the close() method so the Java 7 try-with-resources
block does not automatically close the servlet OutputStream, leaving
this for the caller's finally block.

Change-Id: I84bd3c8031580f805d5d4ef5d70f09b89e170450
1 file changed