diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java index cfc55d8cc..5b84032b1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java @@ -258,9 +258,9 @@ public class ApplyCommand extends GitCommand { if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } - FileWriter fw = new FileWriter(f); - fw.write(sb.toString()); - fw.close(); + try (FileWriter fw = new FileWriter(f)) { + fw.write(sb.toString()); + } getRepository().getFS().setExecute(f, fh.getNewMode() == FileMode.EXECUTABLE_FILE); }