Null object when calling getFixVersions()

Vivian Escalante April 18, 2018

So I get "Cannot invoke method getFixVersions() on null object" when applied to an issue -> issue.getFixVersions(). Anyone know why? I thought it would return empty if there's nothing. 

1 answer

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 18, 2018

The problem is that the issue variable is null. How do you call the script and how you initialize the issue variable?

Vivian Escalante April 19, 2018

Hello, 

Thank you for answering! 

I initialize the variable this way: 

Collection<Version> parentFixVersions = new ArrayList<Version>()

and then set it parentFixVersions = issue.getFixVersions()

I tried to catch the error so, 

if (parentFixVersions == null)

{log.warn("Null Object")} 

But it still gives me the error. 

I'm running this through script runner. 

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 19, 2018

As far as I understand from your previous message the problem was with the issue variable. How do you initialize the issue variable? Where do you run the script?

Suggest an answer

Log in or Sign up to answer