Close/flush the `OutputStream` before calling `toByteArray()` on underlying `ByteArrayOutputStream`
When an OutputStream instance wraps an underlying ByteArrayOutputStream instance,
it is recommended to flush or close the OutputStream before invoking the underlying instances' toByteArray(). Although in some of these case it is not strictly necessary because the
writeObject() method is invoked right before toByteArray(), and writeObject() internally calls flush()/drain(). However, it is good practice to call flush()/close() explicitly as mentioned, for example, here.
This pull request adds a call to close() or flush() before calls to toByteArray().
Coverage remained the same at 95.273% when pulling 3070ab66af7a238428f4ef8b3477ecb1e272cfcf on emopers:flushViolationFixes into b00e65686eb1b11c0b814c4aa0d6a22c03be958c on apache:master.
@emopers Please rebase on master.