jirajira-rest-apijira-rest-java-apiatlassian-plugin-sdkscriptrunner-for-jira

NullPointer exception for issueLinkManager.createIssueLink


I am getting a null pointer for  issueLinkManager.createIssueLink even though all the parameters of the API are not null. I am printing the parameters 1 by 1 and none of them is null. 

Here is my code: 

void createFeature(Issue issue, List<String> componentList){

def issueLinkManager = ComponentAccessor.issueLinkManager

def authenticationContext = ComponentAccessor.jiraAuthenticationContext

def issueFactory = ComponentAccessor.getIssueFactory()

def issueManager = ComponentAccessor.getIssueManager()

def userManager = ComponentAccessor.getUserUtil()

 def currentUserObj = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();

long issueLinkType= 10070

long sequence =1

long newissueTypeID= 19

long myissueID= issue.getId()

MutableIssue newissue= ComponentAccessor.issueFactory.issue

//set values

newissue.setProjectObject(issue.projectObject)

newissue.setIssueTypeId("19") 

newissue.setSummary("MOUNA CAMELIA")

newissue.setDescription("MOUNA CAMELIA")

newissue.reporter = issue.getReporter()

def newIssueCreated = issueManager.createIssueObject(currentUserObj, newissue)

long newIssueCreatedID= newIssueCreated.getId()

                 for(String component: componentList){

                     log.warn("MOUNA CAMELIA ===== myissueID ====="+ myissueID+" =====newissueTypeID ====="+newIssueCreated.getId()

                      +" =====issueLinkType ====="+issueLinkType 

                     +" =====sequence ====="+ sequence +" =====authenticationContext.getLoggedInUser() ====="+authenticationContext.getLoggedInUser()

                     +"issuelinkmanager===="+issueLinkManager)                

                     issueLinkManager.createIssueLink(myissueID, newIssueCreatedID, issueLinkType, sequence, authenticationContext.getLoggedInUser())

         }

}

I printed the values of all the parameters in my log and none of them is null as you can see below: 

MOUNA CAMELIA ===== myissueID =====1521112 =====newissueTypeID =====1782817 =====issueLinkType =====10070 =====sequence =====1 =====authenticationContext.getLoggedInUser() =====mouh(JIRAUSER65000)issuelinkmanager====com.atlassian.jira.issue.link.DefaultIssueLinkManager@49e3bd37

Yet, I am receiving a null pointer exception as you can see here, anyone knows what causes this problem?

enter image description here


Solution

  • The 2 first paramaters needed to be inverted. The 1st parameter represents the child issue and the second parameter represents the parent issue.

       issueLinkManager.createIssueLink( 1782819 as long,1521112 as long, 10070 as long, 1 as long, authenticationContext.getLoggedInUser())