Browse Source

ApplyCommand: Open FileWriter in try-with-resource

Change-Id: Ia473f74dc4608fc43edd57eda4f193c226e9004d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
tags/v4.11.0.201803080745-r
David Pursehouse 6 years ago
parent
commit
40868386db
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java

+ 3
- 3
org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java View File

@@ -258,9 +258,9 @@ public class ApplyCommand extends GitCommand<ApplyResult> {
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);
}

Loading…
Cancel
Save