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();
     }
   }
 }