Use try-with-resources statements

- instead of finally blocks
- in cases of missing try-finally

Change-Id: I94f481a33d8e6a3180c436245d6e95e4d525280c
This commit is contained in:
Urs Wolfer
2015-06-11 21:44:59 +02:00
parent b17ceb8587
commit 5e90c63dea
112 changed files with 727 additions and 1332 deletions

View File

@@ -106,9 +106,8 @@ public class ApprovalCopier {
TreeMap<Integer, PatchSet> patchSets = getPatchSets(cd);
NavigableSet<Integer> allPsIds = patchSets.navigableKeySet();
Repository repo =
repoManager.openRepository(project.getProject().getNameKey());
try {
try (Repository repo =
repoManager.openRepository(project.getProject().getNameKey())) {
// Walk patch sets strictly less than current in descending order.
Collection<PatchSet> allPrior = patchSets.descendingMap()
.tailMap(ps.getId().get(), false)
@@ -132,8 +131,6 @@ public class ApprovalCopier {
}
}
return labelNormalizer.normalize(ctl, byUser.values()).getNormalized();
} finally {
repo.close();
}
} catch (IOException e) {
throw new OrmException(e);