I am using a Jira automation rule and I would like to know which line is causing this nullpointer exception.
I am getting an error message saying that I have a null pointer exception but no indication on which one. How is it possible to know exactly which line is causing this nullpointer exception?
Here is my code:
package SuperFeature
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Logger
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.index.IssueIndexManager
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.event.issue.IssueEventManager
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent
import com.atlassian.jira.event.issue.link.IssueLinkDeletedEvent
import org.apache.log4j.Level
import org.apache.log4j.Logger
import com.atlassian.jira.issue.link.IssueLinkType
def log = Logger.getLogger('atlassian-jira.log')
log.warn("MOUNA: ")
log.warn("MOUNA COMPONENT NUMBERS : "+ issue.getComponents().size())
List<String> componentList = new ArrayList<String>()
def authenticationContext = ComponentAccessor.jiraAuthenticationContext
if (issue.getComponents().size()==0){
log.warn("MOUNA CAMELIA COMPONENTS")
issue.update {
String text= "Issue does not have any components\n"
setCustomFieldValue('Execution Summary', text)
}
}else if(issue.getFixVersions().size()==0){
log.warn("MOUNA CAMELIA VERSIONS")
issue.update {
String text= "Issue does not have any fix versions\n"
setCustomFieldValue('Execution Summary', text)
}
}
else{
log.warn("MOUNA CAMELIA ELSE")
int componentSize=issue.getComponents().size()
for(ProjectComponent component : issue.getComponents()) {
componentList.add(component.getName())
}
issue.update {
String text= "The super feature "+issue+" will be split into "+componentSize+
" features, one for each component:\n"
for(String component: componentList){
text = text +"-"+ component+"\n";
}
setCustomFieldValue('Execution Summary', text)
}
// Issue issue
def issueManager = ComponentAccessor.issueManager
def issueFactory = ComponentAccessor.issueFactory
def subTaskManager = ComponentAccessor.subTaskManager
def issueLinkManager = ComponentAccessor.issueLinkManager
def userManager = ComponentAccessor.userManager
MutableIssue newIssue= ComponentAccessor.issueFactory.issue
newIssue.setProjectObject(issue.getProjectObject())
newIssue.setSummary("MOUNA CAMELIA")
newIssue.issueTypeId= 10070
int issueLinkType= 10070
int sequence =1
newIssue.setAssignee(userManager.getUserByName("mouh"))
newIssue.setDescription(issue.getDescription())
for(String component: componentList){
log.warn("MOUNA CAMELIA component"+ component +" NEW ISSUE "+ newIssue)
log.warn("MOUNA CAMELIA Component "+ component+" issue.getId() "+ issue.getId()+" issueLinkType "+issueLinkType+" sequence "+ sequence+" auth "+authenticationContext.getLoggedInUser())
issueLinkManager.createIssueLink(issue.getId(), newIssue.getIssueTypeId(), issueLinkType, sequence, authenticationContext.getLoggedInUser())
}
}
What about any message in the log files?