Do not remove replication tasks if they are retrying

Prevent the premature removal of replication tasks when they
are scheduled for retry. The termination of a PushOp does not
necessarily mean that the operation was successful or was definitely
cancelled: there is also the possibility of retrying upon failures.

Fix an issue where the replication task storage was attempting
to remove the persistent task and, luckily, failing because the
task was put back into the waiting queue.

Bug: Issue 12073
Change-Id: I4751f427aa1c45a8a36232d74e0a6691f860e490
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 53fb392..79cddca 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
@@ -586,7 +586,9 @@
 
   void notifyFinished(PushOne op) {
     synchronized (stateLock) {
-      replicationTasksStorage.get().finish(op);
+      if (!op.isRetrying()) {
+        replicationTasksStorage.get().finish(op);
+      }
       inFlight.remove(op.getURI());
     }
   }