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

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


      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;

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