My plugin is now catching the event listener onBuildStatusSet to search for a pull request corresponding to the commit that was just updated (for the build status) and adds a comment in that pull request.
However, it seems to cause issues. After a while, I have errors mentioning RejectedExecutionException.
I searched and found this https://confluence.atlassian.com/bitbucketserverkb/rejectedexecutionexception-779171377.html?utm_medium=logScan&utm_source=STP
Seems that to not impact Bitbucket's performances, I have to dispatch my processing to a separate thread. How would I go about doing that?
public class UpdatePullRequestComments { @EventListener public void onBuildStatusSet(BuildStatusSetEvent event) { TriggerUpdatePR(event.getCommitId(), buildStatus); } }
Ideally, I would like to call `TriggerUpdatePR` on a separate thread.
EDIT:
I just found java.util.concurrent.ExecutorService
public class UpdatePullRequestComments { @EventListener public void onBuildStatusSet(BuildStatusSetEvent event) { executorService.submit(() -> TriggerUpdatePR(event.getCommitId(), buildStatus)); } }
Would that do the trick or I will have the same issue?
Community moderators have prevented the ability to post new answers.
Executorservice does the job perfectly
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.