RefUpdateTest: Use try-with-resource for auto-closable types
Change-Id: I25c8db0e410aa2a4a53dc7d8863e4a6efefcf7cb Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
This commit is contained in:
parent
56634de0cc
commit
0352276da7
|
@ -558,7 +558,8 @@ public void testUpdateRefForwardWithCheck2() throws IOException {
|
|||
assertEquals(ppid, db.resolve("refs/heads/master"));
|
||||
|
||||
// real test
|
||||
RevCommit old = new RevWalk(db).parseCommit(ppid);
|
||||
try (RevWalk rw = new RevWalk(db)) {
|
||||
RevCommit old = rw.parseCommit(ppid);
|
||||
RefUpdate updateRef2 = db.updateRef("refs/heads/master");
|
||||
updateRef2.setExpectedOldObjectId(old);
|
||||
updateRef2.setNewObjectId(pid);
|
||||
|
@ -566,6 +567,7 @@ public void testUpdateRefForwardWithCheck2() throws IOException {
|
|||
assertEquals(Result.FAST_FORWARD, update2);
|
||||
assertEquals(pid, db.resolve("refs/heads/master"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try modify a ref that is locked
|
||||
|
@ -707,10 +709,11 @@ public void testRenameBranchAlsoInPack() throws IOException {
|
|||
|
||||
// Create new Repository instance, to reread caches and make sure our
|
||||
// assumptions are persistent.
|
||||
Repository ndb = new FileRepository(db.getDirectory());
|
||||
try (Repository ndb = new FileRepository(db.getDirectory())) {
|
||||
assertEquals(rb2, ndb.resolve("refs/heads/new/name"));
|
||||
assertNull(ndb.resolve("refs/heads/b"));
|
||||
}
|
||||
}
|
||||
|
||||
public void tryRenameWhenLocked(String toLock, String fromName,
|
||||
String toName, String headPointsTo) throws IOException {
|
||||
|
|
Loading…
Reference in New Issue