Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-34376

Issues not committed to database (and cannot be fetched) at time of event dispatch for issues created from post function

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Low
    • None
    • 5.2.9, 6.0, 6.1-EAP
    • Issue - View Issue

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              7c60ab039b09 Scott Dudley [Inactive]
              Votes:
              3 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated: