Integrated: 1058: The mlbridge bot occasionally posts the same comments twice on Github

Erik Joelsson erikj at openjdk.java.net
Fri Jul 16 07:05:33 UTC 2021


On Thu, 15 Jul 2021 13:30:57 GMT, Erik Joelsson <erikj at openjdk.org> wrote:

> 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.

This pull request has now been integrated.

Changeset: fd42d900
Author:    Erik Joelsson <erikj at openjdk.org>
URL:       https://git.openjdk.java.net/skara/commit/fd42d900459c2e1c9301ab341ad6f081cc0bf4b2
Stats:     38 lines in 10 files changed: 9 ins; 18 del; 11 mod

1058: The mlbridge bot occasionally posts the same comments twice on Github

Reviewed-by: kcr

-------------

PR: https://git.openjdk.java.net/skara/pull/1202


More information about the skara-dev mailing list