Closing a ByteArrayOutputStream does nothing, apparently. It looks like garbage collection should clean up that object after parseCommand() returns.
Most JVM garbage collection is non-deterministic. My understanding is that just because an object goes out of scope, does not mean it will get garbage collected. Regardless of that, I see in the documentation that the
close() method "does nothing".
I was interested enough to do some googling, as my understanding of best practices says that all streams should be closed when you're finished with them.
Here's what my searching came up with, feel free to read for yourself and make the decision as you see fit.
Also I should note that the
close() method should probably be part of a
finally block, which is not the case in the patch I provided.