Uploaded image for project: 'Jira Server and Data Center'
  1. Jira Server and Data Center
  2. JRASERVER-59733

Can't create and read an issue type from within the same database transaction

    XMLWordPrintable

Details

    Description

      We are building an add-on which does some changes to the JIRA configuration.
      With JIRA 7 we hit the following issue:

      1. Open a transaction with the com.atlassian.jira.transaction.Txn API
      2. Create an issue type using IssueTypeManager.createIssueType()
      3. Get the newly created issue type by id using ConstanstsManager.getIssueTypeObject(id)

      Result: The last call returns null. If transactions are disabled everything works correctly.
      We tracked down the problem to the fact that DefaultsConstantManager.IssueTypeCacheLoader opens a new DB connection and completely ignores the current transaction.

      This effectively means that transactions are unusable with JIRA 7.

      Here is a simple groovy script to reproduce (with Script Runner). Comment out the Txn.begin() call and everything will work:

      import com.atlassian.jira.transaction.Txn
      import com.atlassian.jira.component.ComponentAccessor
      import com.atlassian.jira.config.IssueTypeManager
      
      def transaction = Txn.begin();
      def issueTypeManager = ComponentAccessor.getComponent(IssueTypeManager.class);
      
      def issueType = issueTypeManager.createIssueType("New Issue Type", "Description", 0l);
      
      def constantsManager = ComponentAccessor.getConstantsManager();
      def newIssueType = constantsManager.getIssueTypeObject(issueType.getId());
      
      assert newIssueType != null;
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            211a55f4812b Petar Petrov (Appfire)
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: