ListBranches: Use Repository in try-with-resources
Change-Id: I43a1c6950f4181f43c08b140857854e438aca6be
This commit is contained in:
@@ -88,14 +88,7 @@ public class ListBranches implements RestReadView<ProjectResource> {
|
||||
BranchInfo configBranch = null;
|
||||
final Set<String> targets = Sets.newHashSet();
|
||||
|
||||
final Repository db;
|
||||
try {
|
||||
db = repoManager.openRepository(rsrc.getNameKey());
|
||||
} catch (RepositoryNotFoundException noGitRepository) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
|
||||
try {
|
||||
try (Repository db = repoManager.openRepository(rsrc.getNameKey())) {
|
||||
List<Ref> refs =
|
||||
new ArrayList<>(db.getRefDatabase().getRefs(Constants.R_HEADS)
|
||||
.values());
|
||||
@@ -157,8 +150,8 @@ public class ListBranches implements RestReadView<ProjectResource> {
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
} catch (RepositoryNotFoundException noGitRepository) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
Collections.sort(branches, new Comparator<BranchInfo>() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user