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