[CODEC-183] BaseNCodecOutputStream only supports writing EOF on close() (original) (raw)

The only way to add the EOF marker when encoding or decoding with the BaseNCodecOutputStream is via the close() function. The flush() function does not perform this logic, and it is questionable whether or not it should.

The problem is that I want to write to a Base64OutputStream in the middle of writing to another stream. That is, I will write some content to a stream, then wrap that stream with a Base64OutputStream to write some more (encoded) content, and then finish writing directly to the original stream (and so not encoded). Calling flush() on the Base64OutputStream will not write the EOF marker, which means bytes can be lost. I do not want to call close() on the Base64OutputStream as that will propagate to my original stream, which I need to leave open.

Ideas for resolving this include the following: