Static Type Checking Errors Edited

Hi, 
We are using Jira 6.3 and wanted to upgrade to Jira 7.0.11. I tested few of the existing scripts on the new server, but ended up with lot of errors. Most of these errors are related to type casting because of deprecated versions. I tried fixing most of them, but have a problem with one function call in my script.

 

The error is [Static type checking] - Cannot return value of type java.lang.Object on method returning type com.atlassian.jira.user.ApplicationUser.

 

The line where the error is in the below code snippet where I am trying to return the ApplicationUser, but the return type of qaContact?.getValue(foundIssue) is an Object.

Code Snippet:

if (foundIssue != null)

{

def qaContact = ComponentAccessor.getCustomFieldManager().getCustomFieldObjects(foundIssue).find {it.name.equals(FIELD_NAME)}

return qaContact?.getValue(foundIssue)

}

How can I fix this issue?

 

Thanks in advance.

1 answer

Hi invinci,

This is because due to there being multiple types of custom fields returning different object classes (Lists, Maps, Strings, Long, etc.) The javadoc lists the return value as being a simple Object.

Despite the typechecking returning an error, that code should run, assuming that the QAcontact field is a user field.  Alternatively, you might get around the error by casting the result to ApplicationUser first:

return (ApplicationUser)qaContact?.getValue(foundIssue)

Eric

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,270 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot