-
Bug
-
Resolution: Answered
-
Low
-
None
-
7.0.10
-
7
-
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;