From 40868386dbe9da7c3eb23f6495a655f536f8a14b Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Mon, 5 Mar 2018 20:17:32 +0900 Subject: [PATCH] ApplyCommand: Open FileWriter in try-with-resource Change-Id: Ia473f74dc4608fc43edd57eda4f193c226e9004d Signed-off-by: David Pursehouse --- org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); }