Affects Version/s: None
Fix Version/s: None
BinaryOutputArchive internally uses DataOutputStream as its stream, and when a DataOutputStream instance wraps an underlying ByteArrayOutputStream instance,
it is recommended to flush or close the DataOutputStream before invoking the underlying instances's toByteArray() . Also, it is a good practice to call flush/close explicitly as mentioned for example http://stackoverflow.com/questions/2984538/how-to-use-bytearrayoutputstream-and-dataoutputstream-simultaneously-java.
Moreover, "baos.close()" at second last line is not required as it is no-op according to javadoc
Closing a ByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.
The patch is to add flush method on "bos" before calling toByteArray on "baos". Similar behavior is also present in the following files:
Let me know if this looks good. I can provide patch.