Browse Source

CommitCommand: Open InputStream in try-with-resource

Change-Id: I800a2afae17f84636cae593be7f07628fb8476c1
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.11
David Pursehouse 7 years ago
parent
commit
3393f78210
  1. 7
      org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java

7
org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java

@ -409,14 +409,11 @@ public class CommitCommand extends GitCommand<RevCommit> {
inserter = repo.newObjectInserter(); inserter = repo.newObjectInserter();
long contentLength = fTree long contentLength = fTree
.getEntryContentLength(); .getEntryContentLength();
InputStream inputStream = fTree try (InputStream inputStream = fTree
.openEntryStream(); .openEntryStream()) {
try {
dcEntry.setObjectId(inserter.insert( dcEntry.setObjectId(inserter.insert(
Constants.OBJ_BLOB, contentLength, Constants.OBJ_BLOB, contentLength,
inputStream)); inputStream));
} finally {
inputStream.close();
} }
} }
} }

Loading…
Cancel
Save