-
Bug
-
Resolution: Unresolved
-
Low
-
None
-
5.2.9, 6.0, 6.1-EAP
-
5.02
-
3
-
Severity 3 - Minor
-
1
-
JIRA can be configured to create an issue as part of a post function, using third-party tools such as Script Runner. Additionally, when an issue is created, the "Issue Created" event should be fired and propagated to listeners.
However, if an issue is created as part of a post function, the issue will not be committed to the database by the time the event is dispatched. For example, with an event listener similar to the following:
@EventListener public void onIssueEvent(IssueEvent issueEvent) { Long eventTypeId = issueEvent.getEventTypeId(); Issue issue = issueEvent.getIssue(); if (eventTypeId.equals(EventType.ISSUE_CREATED_ID)) { Issue i2 = issueManager.getIssueObject(issue.getId()); // ... }
When an issue is created normally (such as by clicking the "Create Issue" button), "i2" points to the same issue that is made available via issueEvent.getIssue().
However, if this is executed as a post function (for example, using Script Runner 2.1.9 with the canned "Clones an issue and links" script), then "i2" is null.
This presumably happens because the post function is executed inside a transaction via OSWorkflowManager.doWorkflowActionInsideTxn, and the transaction does not get committed until the post function returns (which is long after the event handler has been run).
There are some scary comments in OSWorkflowManager.createIssue() indicating that transactions around a "Create Issue" can potentially cause deadlock or duplicate issue keys (JRADEV-7958, JRA-25914), which might or might not be relevant to this specific case...although if this listener tries to create another issue based on this event, I imagine that the end result would not be pretty.
- is related to
-
JRASERVER-40597 Issue events fired from a workflow transition should happen after the transaction is committed
- Closed
-
JRASERVER-67880 Wrong data can be cached in Jira while in post function creating issue or changing label custom field value
- Closed
- relates to
-
JRASERVER-25914 Two issues created with the same pkey value...
- Closed
-
JRASERVER-26172 Creating an issue from a transition can lock the database under load.
- Closed
-
JRASERVER-33256 Restrict Post Functions to Sensible Timings
- Closed