summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2015-08-27 14:06:38 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2015-08-27 14:06:38 +0900
commitcc91e0c2987a4606e19b10e320b14f6a0c911c06 (patch)
tree8b3fdee6c954649cd8e05e0aa2ee9168f118baf6 /src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
parent264b7a00361f8a880cbad389523bf329f1989480 (diff)
Open Repository in try-with-resource
Diffstat (limited to 'src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java')
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
index 49edc41..60810b8 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
@@ -235,27 +235,23 @@ class Destination {
e = pending.get(uri);
}
if (e == null) {
- Repository git;
- try {
- git = gitManager.openRepository(project);
- } catch (IOException err) {
- stateLog.error(String.format(
- "source project %s not available", project), err, state);
- return;
- }
- try {
- Ref head = git.getRef(Constants.HEAD);
- if (head != null
- && head.isSymbolic()
- && RefNames.REFS_CONFIG.equals(head.getLeaf().getName())) {
+ try (Repository git = gitManager.openRepository(project)) {
+ try {
+ Ref head = git.getRef(Constants.HEAD);
+ if (head != null
+ && head.isSymbolic()
+ && RefNames.REFS_CONFIG.equals(head.getLeaf().getName())) {
+ return;
+ }
+ } catch (IOException err) {
+ stateLog.error(String.format(
+ "cannot check type of project %s", project), err, state);
return;
}
} catch (IOException err) {
stateLog.error(String.format(
- "cannot check type of project %s", project), err, state);
+ "source project %s not available", project), err, state);
return;
- } finally {
- git.close();
}
}
}