]> source.dussan.org Git - jgit.git/commit
Close 'out' consistently in ArchiveCommand.call 01/48901/1
authorJonathan Nieder <jrn@google.com>
Wed, 27 May 2015 23:25:32 +0000 (16:25 -0700)
committerJonathan Nieder <jrn@google.com>
Wed, 27 May 2015 23:49:12 +0000 (16:49 -0700)
commit1287cdaf338c4f1b782985597de9358de534bbef
tree6625a3955e92a8bd9e8ae54b8c2292d4690ed006
parentebfd62433a58d23af221adfdffed56d9274f4268
Close 'out' consistently in ArchiveCommand.call

Whether the output stream specified with setOutputStream() is closed by
ArchiveCommand.call() is murky and inconsistent:

- on success, it is closed
- if an exception is encountered when writing the archive, it is closed
- if an exception is encountered when calling createArchiveStream to
  open the archive, we forget to close it

Close the output stream consistently to avoid leaks.

Now that the inner try-with-resources doesn't have its own finally
block, this allows us to merge the two try blocks.

It would be even better to never close the output stream.  That will
involve more API changes to avoid silently breaking callers, so it is
deferred to a later change.

Change-Id: I0185bdaa60ecee4a541eab5d8ff6c9c4dbe40bf1
Signed-off-by: Jonathan Nieder <jrn@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java