diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java index 8a89ba161..f2572835f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java @@ -409,14 +409,11 @@ private DirCache createTemporaryIndex(ObjectId headId, DirCache index, inserter = repo.newObjectInserter(); long contentLength = fTree .getEntryContentLength(); - InputStream inputStream = fTree - .openEntryStream(); - try { + try (InputStream inputStream = fTree + .openEntryStream()) { dcEntry.setObjectId(inserter.insert( Constants.OBJ_BLOB, contentLength, inputStream)); - } finally { - inputStream.close(); } } }