RFR: 1058: The mlbridge bot occasionally posts the same comments twice on Github
Erik Joelsson
erikj at openjdk.java.net
Thu Jul 15 13:34:14 UTC 2021
This patch (hopefully) fixes an issue where sometimes the mlbridge bot would post the same email as comment twice in a PR. This happens because two instances of the CommentPosterWorkItem are running at the same time for the same PullRequest.
This is supposed to be protected by the method "concurrentWith(WorkItem other)". In this particular case, the check is faulty. It checks if the PullRequest object in this WorkItem is equal to the object in the other WorkItem. This is default Object equality, and there is definitely no guarantee that they both contain the exact same object.
Looking around in other implementations of this method, there is mix of how stringent the checks are, some only check if the PullRequest.id() field is the same, but most also check something about the HostedRepository to which the PR belongs (either name or url). I think calculating the url seems a bit expensive for an equals check.
I propose a new method on the PullRequest interface: "isSame(PullRequest other)". This isn't trying to be an equals, as that's a bit hard to define (and I don't want to get into implementing hashCode at this time), but will just return true if both PullRequest instances are logically referring to the same hosted pull request. I have replaced all uses of PullRequest.equals() and PullRequest.id().equals() with this new method for consistency.
-------------
Commit messages:
- SKARA-1058
Changes: https://git.openjdk.java.net/skara/pull/1202/files
Webrev: https://webrevs.openjdk.java.net/?repo=skara&pr=1202&range=00
Issue: https://bugs.openjdk.java.net/browse/SKARA-1058
Stats: 38 lines in 10 files changed: 9 ins; 18 del; 11 mod
Patch: https://git.openjdk.java.net/skara/pull/1202.diff
Fetch: git fetch https://git.openjdk.java.net/skara pull/1202/head:pull/1202
PR: https://git.openjdk.java.net/skara/pull/1202
More information about the skara-dev
mailing list