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

Loading…
Cancel
Save