I’d like to create a ScriptRunner listener that updates the issue, in a way that sends the “issue updated” event to trigger (cascade to) some other listeners. Firing that event will call original listener again, with some performance overhead, log noise, and some risk of infinite loop.
Imagine two listeners:
- When field X changes, then put the value in Y. If Y changes, revert it to contain value of X. IOW keep two fields in sync.
- When Y changes, then update some other field Z.
What happens is:
- X changes, so we update Y.
- That update calls listener 1 again, which now needs nontrivial logic for “loop detection”. And it’s wasting precious time.
- That update calls listener 2. It updates Z.
- Updating Z calls listener 1 and 2 again. More complexity and wasted time.
How can I prevent this?
Is some kind of thread-local storage available in SR?
Is there a utility somewhere in ScriptRunner or Jira that would let me identify the event/listener chain that has been executed on the thread so far?