Make persistent task keys stable

GSON was used to create json as the input for sha1 task keys, however
gson can order the json keys differently anytime. Use the values in a
specific order to create stable keys.

Bug: Issue 11760
Change-Id: I6900b5ddb3ba8ab7b5cf7803ae9dd551b5980a59
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java
index 19becdf..b1fbb10 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java
@@ -69,7 +69,8 @@
 
   public String persist(ReplicateRefUpdate r) {
     String json = GSON.toJson(r) + "\n";
-    String eventKey = sha1(json).name();
+    String key = r.project + "\n" + r.ref + "\n" + r.uri + "\n" + r.remote;
+    String eventKey = sha1(key).name();
     Path file = refUpdates().resolve(eventKey);
 
     if (Files.exists(file)) {
@@ -91,8 +92,8 @@
   }
 
   public void delete(ReplicateRefUpdate r) {
-    String taskJson = GSON.toJson(r) + "\n";
-    String taskKey = sha1(taskJson).name();
+    String key = r.project + "\n" + r.ref + "\n" + r.uri + "\n" + r.remote;
+    String taskKey = sha1(key).name();
     Path file = refUpdates().resolve(taskKey);
 
     if (disableDeleteForTesting) {