Browse Source

RecursiveMergerTest: Open FileOutputStream in try-with-resource

Change-Id: I158333d6393fb807bc21fba23fec7ad474384471
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.11
David Pursehouse 7 years ago
parent
commit
ca7d3e2734
  1. 23
      org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/RecursiveMergerTest.java

23
org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/RecursiveMergerTest.java

@ -817,10 +817,6 @@ public class RecursiveMergerTest extends RepositoryTestCase {
void modifyWorktree(WorktreeState worktreeState, String path, String other) void modifyWorktree(WorktreeState worktreeState, String path, String other)
throws Exception { throws Exception {
FileOutputStream fos = null;
ObjectId bloblId;
try {
switch (worktreeState) { switch (worktreeState) {
case Missing: case Missing:
new File(db.getWorkTree(), path).delete(); new File(db.getWorkTree(), path).delete();
@ -830,14 +826,17 @@ public class RecursiveMergerTest extends RepositoryTestCase {
Integer.toString(counter++)); Integer.toString(counter++));
break; break;
case SameAsHead: case SameAsHead:
bloblId = contentId(Constants.HEAD, path); try (FileOutputStream fos = new FileOutputStream(
fos = new FileOutputStream(new File(db.getWorkTree(), path)); new File(db.getWorkTree(), path))) {
db.newObjectReader().open(bloblId).copyTo(fos); db.newObjectReader().open(contentId(Constants.HEAD, path))
.copyTo(fos);
}
break; break;
case SameAsOther: case SameAsOther:
bloblId = contentId(other, path); try (FileOutputStream fos = new FileOutputStream(
fos = new FileOutputStream(new File(db.getWorkTree(), path)); new File(db.getWorkTree(), path))) {
db.newObjectReader().open(bloblId).copyTo(fos); db.newObjectReader().open(contentId(other, path)).copyTo(fos);
}
break; break;
case Bare: case Bare:
if (db.isBare()) if (db.isBare())
@ -848,10 +847,6 @@ public class RecursiveMergerTest extends RepositoryTestCase {
db = new FileRepository(new File(workTreeFile, "test.git")); db = new FileRepository(new File(workTreeFile, "test.git"));
db_t = new TestRepository<>(db); db_t = new TestRepository<>(db);
} }
} finally {
if (fos != null)
fos.close();
}
} }
private boolean validateStates(IndexState indexState, private boolean validateStates(IndexState indexState,

Loading…
Cancel
Save