-
-
Save emopers/b8cd798fb22ed1e28949 to your computer and use it in GitHub Desktop.
baos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Title: | |
Closing DataOutputStream before calling toByteArray on the underlying ByteArrayOutputStream | |
Subject: | |
When an DataOutputStream instance wraps an underlying ByteArrayOutputStream instance, | |
it is recommended to flush or close the ObjectOutputStream before invoking the underlying instances's toByteArray(). | |
Although in these cases this is not strictly necessary because the | |
DataOutputStream flush and close method have no effect. However, it is a good practice to call | |
flush/close explicitly as mentioned for example (here) | |
[http://stackoverflow.com/questions/2984538/how-to-use-bytearrayoutputstream-and-dataoutputstream-simultaneously-java] | |
This pull request adds close methods to close DataOutputStream. Even in the cases where DataOutputStream can | |
wrap any OutputStream like EncryptionParameters.java#writeTo, I added close method because some of the tests like EncryptionParametersTest.java | |
wraps them with ByteArrayOutputStream and then calls toByteArray. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment