Browse Source

ApplyCommand: Open FileWriter in try-with-resource

Change-Id: Ia473f74dc4608fc43edd57eda4f193c226e9004d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.11
David Pursehouse 7 years ago
parent
commit
40868386db
  1. 6
      org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java

6
org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java

@ -258,9 +258,9 @@ public class ApplyCommand extends GitCommand<ApplyResult> {
if (sb.length() > 0) { if (sb.length() > 0) {
sb.deleteCharAt(sb.length() - 1); sb.deleteCharAt(sb.length() - 1);
} }
FileWriter fw = new FileWriter(f); try (FileWriter fw = new FileWriter(f)) {
fw.write(sb.toString()); fw.write(sb.toString());
fw.close(); }
getRepository().getFS().setExecute(f, fh.getNewMode() == FileMode.EXECUTABLE_FILE); getRepository().getFS().setExecute(f, fh.getNewMode() == FileMode.EXECUTABLE_FILE);
} }

Loading…
Cancel
Save