Use try-with-resources to fix eclipse warnings
Change-Id: I68b9d5034ded87294afa5b66b395ceeb17724afa
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
index 17f1813..002361a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
@@ -375,18 +375,10 @@
}
private void runImpl() throws IOException {
- Transport tn = Transport.open(git, uri);
PushResult res;
- try {
+ try (Transport tn = Transport.open(git, uri)) {
res = pushVia(tn);
- } finally {
- try {
- tn.close();
- } catch (Throwable e2) {
- repLog.warn("Unexpected error while closing " + uri, e2);
- }
}
-
updateStates(res.getRemoteUpdates());
}
@@ -506,11 +498,8 @@
private Map<String, Ref> listRemote(Transport tn)
throws NotSupportedException, TransportException {
- FetchConnection fc = tn.openFetch();
- try {
+ try (FetchConnection fc = tn.openFetch()) {
return fc.getRefsMap();
- } finally {
- fc.close();
}
}