Merge branch 'stable-2.16' into stable-3.0

* stable-2.16:
  Make sure to always remove in-flight pushes

Change-Id: I574e150181d4cc63c8ebf6371b05093ee569c093
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 3ef1707..168c95f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
@@ -389,10 +389,10 @@
     } catch (PermissionBackendException | RuntimeException | Error e) {
       stateLog.error("Unexpected error during replication to " + uri, e, getStatesAsArray());
     } finally {
+      pool.notifyFinished(this);
       if (git != null) {
         git.close();
       }
-      pool.notifyFinished(this);
     }
   }