Is there an automated loop detection for onIssueEvent

Emre Toptancı _OBSS_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 7, 2018

I want to ask about something that is working to my benefit but I am not sure that I understand why it happens that way.

I am using onIssueEvent method for handling issue events, including "issue updated" event. In my event handler I call IssueManager.updateIssue() for another issue and the update event is intentionally dispatched for the target issue:

@EventListener
public void onIssueEvent(IssueEvent issueEvent){
 log.debug("handling update for " + issueEvent.getIssue().getKey());
/* some event handling code */
issueManager.updateIssue(user,
targetIssue,
EventDispatchOption.ISSUE_UPDATED,
false
);
/* some more event handling code */
log.debug("handled update for " + issueEvent.getIssue().getKey());
}

In an example based on the data on my system:

  1. Issue A is updated by the user
  2. The update event handler for issue A dispatches an update event for issue B
  3. The update event handler for issue B dispatches an update event for issue C
  4. Finally the update event handler for issue C dispatches back an update event for issue A
  5. And so on ... (at least it was expected to be)

Somehow the log output I get is something like below:

handling update for A
handling update for B
handling update for C
handled update for C
handled update for B
handled update for A

First, I was expecting IssueManager.updateIssue() method to fire an event that would be handled AFTER the current event handler finishes but somehow it acts like a method call. My event handler for Issue A resumes after B and C are finished handling their events.

Second, I was expecting to face an infinite loop and was prepared to search for a way to break it but the event handler on issue C does not dispatch an update event back to issue A, even tough it is instructed to do so.

So, all of these are against my expectations. Can someone shed a light on why it is happening this way?

(Jira 7.5.0)

0 answers

Suggest an answer

Log in or Sign up to answer