summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fick <mfick@codeaurora.org>2019-10-16 12:24:13 -0600
committerNasser Grainawi <nasser@codeaurora.org>2020-05-20 12:20:36 -0600
commit2cb6112e081e97d4dfd8e677b6f02c779db95e85 (patch)
treea589ecb7c5f808cdc4c49700b5d15b68d3320a37
parent8738fded0d6e0240e748b950a4a9b84ac8595896 (diff)
Make persistent task keys stablev2.16.19
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
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java7
1 files changed, 4 insertions, 3 deletions
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 class ReplicationTasksStorage {
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 class ReplicationTasksStorage {
}
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) {