Avoid possible memory leaks by ensuring stream closures

Stream close() methods should always be called in finally block
to ensure we don't accidentally leak a stream.

Change-Id: I3460b558ed5b4489296388c9a52fbb773cefd31f
Merge "Avoid possible memory leaks by ensuring stream closures" into jb4.2