diff options
author | Luca Milanesio <luca.milanesio@gmail.com> | 2024-01-11 23:43:23 +0000 |
---|---|---|
committer | Luca Milanesio <luca.milanesio@gmail.com> | 2024-01-11 23:51:07 +0000 |
commit | e2e7d68c093fd790c60b976736a05d8962a6fe98 (patch) | |
tree | 802ce7ac06563fd7fdde6808fcdb256dfc44b738 | |
parent | 18408fb7e2366695660f685a9016fe783203073d (diff) |
Complete comment identity with the associated serverId in comments
Change note-db /meta ref contains the list of change notes associated,
including all the comments were added to files and commit messages.
The remapping of account-ids performed with I4b0fe6689 has correctly
adapted the comment's author account-ids to the local associated
accounts, however, it failed to update the comment serverId, leaving
the rest of Gerrit with an inconsistent identity.
Even though the identity was not causing apparent damage, mostly
because the serverId was ignored mainly by Gerrit; it left the cached
entities with the incorrect data and, in some cases, persisted back
to NoteDb (see Issue 318745940).
Rectify the situation by updating the serverId when accounts are
remapped.
Release-Notes: Fix serverId in identity parsing for imported human comments
Forward-Compatible: checked
Bug: Issue 318745940
Change-Id: I5904dc46120858beb54e20ac339f10a02d785d3a
3 files changed, 7 insertions, 2 deletions
diff --git a/java/com/google/gerrit/server/notedb/ChangeNotesParser.java b/java/com/google/gerrit/server/notedb/ChangeNotesParser.java index f964d4eb4d..e8b75b1182 100644 --- a/java/com/google/gerrit/server/notedb/ChangeNotesParser.java +++ b/java/com/google/gerrit/server/notedb/ChangeNotesParser.java @@ -893,7 +893,11 @@ class ChangeNotesParser { noteDbUtil .parseIdent(String.format("%s@%s", c.author.getId(), c.serverId)) - .ifPresent(id -> c.author = new Comment.Identity(id)); + .ifPresent( + id -> { + c.author = new Comment.Identity(id); + c.serverId = noteDbUtil.serverId; + }); humanComments.put(e.getKey(), c); } diff --git a/java/com/google/gerrit/server/notedb/NoteDbUtil.java b/java/com/google/gerrit/server/notedb/NoteDbUtil.java index 0c0238df65..3b467c4227 100644 --- a/java/com/google/gerrit/server/notedb/NoteDbUtil.java +++ b/java/com/google/gerrit/server/notedb/NoteDbUtil.java @@ -35,7 +35,7 @@ import org.eclipse.jgit.util.GitDateFormatter.Format; @Singleton public class NoteDbUtil { - private final String serverId; + final String serverId; private final ExternalIdCache externalIdCache; @Inject diff --git a/javatests/com/google/gerrit/server/notedb/ImportedChangeNotesTest.java b/javatests/com/google/gerrit/server/notedb/ImportedChangeNotesTest.java index 57be12c982..366cbf736e 100644 --- a/javatests/com/google/gerrit/server/notedb/ImportedChangeNotesTest.java +++ b/javatests/com/google/gerrit/server/notedb/ImportedChangeNotesTest.java @@ -133,6 +133,7 @@ public class ImportedChangeNotesTest extends AbstractChangeNotesTest { assertThat(comments).hasSize(1); HumanComment gotComment = comments.entries().asList().get(0).getValue(); assertThat(gotComment.author.getId()).isEqualTo(otherUser.getAccountId()); + assertThat(gotComment.serverId).isEqualTo(LOCAL_SERVER_ID); } @Test |