commit | 720434438642f55d1f6c0f250702f4238576a8e6 | [log] [tgz] |
---|---|---|
author | David Pursehouse <david.pursehouse@sonymobile.com> | Wed Dec 02 14:27:18 2015 +0900 |
committer | David Pursehouse <david.pursehouse@sonymobile.com> | Wed Dec 02 14:27:18 2015 +0900 |
tree | 309b6361f0671d6b51bc2908e0f3bea6fc29c1a9 | |
parent | 818ad6528aff74e2d1ffc1e4fcfab2ae1fbd3dda [diff] |
Open Repository and PlotWalk in try-with-resource Change-Id: Ifcbb7a601314d8f48282be1ab0f0fe9176c547e0
diff --git a/src/main/java/com/googlesource/gerrit/plugins/branchnetwork/data/JGitFacade.java b/src/main/java/com/googlesource/gerrit/plugins/branchnetwork/data/JGitFacade.java index f0f0ab8..f0395b3 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/branchnetwork/data/JGitFacade.java +++ b/src/main/java/com/googlesource/gerrit/plugins/branchnetwork/data/JGitFacade.java
@@ -166,11 +166,8 @@ } public int getBranchesPlotLanesCount(String repoName) throws IOException { - final Repository repo = - repoManager.openRepository(NameKey.parse(repoName)); - final PlotWalk walk = new PlotWalk(repo); - - try { + try (Repository repo = repoManager.openRepository(NameKey.parse(repoName)); + PlotWalk walk = new PlotWalk(repo);) { ObjectId headId = repo.resolve(Constants.HEAD); if (headId == null) return 0; @@ -188,9 +185,6 @@ } return maxLane; - } finally { - walk.dispose(); - repo.close(); } } }