Custom field issue during indexing

We have found this issue during indexing.  It points to a custom field that uses the Groovy Runner.  The field is scripted as follows

 

def templateType = getCustomFieldValue("Template Type").value;
def multiplier = (templateType == "NEQL"
? 500
: (templateType == "N+"
? 100
: 0));

def estimate = multiplier * issue.getOriginalEstimate() / 3600;

return String.format( '%,d', estimate as int);

This is the error generated by the reindex process.  Any pointers?

2015-07-22 12:55:23,775 JiraTaskExectionThread-1 INFO chapmar 775x103x1 mmgxax 127.0.0.1 /secure/admin/IndexReIndex.jspa [jira.util.index.CompositeIndexLifecycleManager] Reindex All starting...
2015-07-22 12:55:23,823 JiraTaskExectionThread-1 INFO chapmar 775x103x1 mmgxax 127.0.0.1 /secure/admin/IndexReIndex.jspa [action.admin.index.IndexAdminImpl] Re-indexing is 0% complete. Current index: Issue
2015-07-22 12:55:23,871 JiraTaskExectionThread-1 INFO chapmar 775x103x1 mmgxax 127.0.0.1 /secure/admin/IndexReIndex.jspa [jira.issue.index.DefaultIndexManager] Reindexing: {indexIssues=true, indexChangeHistory=true, indexComments=true, indexWorklogs=true}
2015-07-22 12:55:49,759 IssueIndexer:thread-2 INFO chapmar 775x103x1 mmgxax 127.0.0.1 /secure/admin/IndexReIndex.jspa [action.admin.index.IndexAdminImpl] Re-indexing is 1% complete. Current index: Issue
2015-07-22 12:55:52,690 IssueIndexer:thread-8 ERROR chapmar 775x103x1 mmgxax 127.0.0.1 /secure/admin/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] *************************************************************************************
2015-07-22 12:55:52,694 IssueIndexer:thread-8 ERROR chapmar 775x103x1 mmgxax 127.0.0.1 /secure/admin/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: UDR-15, field: Estimated Cost
groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.lang.Integer#multiply.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
        [class java.lang.Character]
        [class java.lang.Number]
        at Script2.run(Script2.groovy:8)
.....
2015-07-22 13:31:55,467 IssueIndexer:thread-10 INFO chapmar 775x103x1 mmgxax 127.0.0.1 /secure/admin/IndexReIndex.jspa [action.admin.index.IndexAdminImpl] Re-indexing is 98% complete. Current index: Issue

 

Regards,

 

Roy

2 answers

1 accepted

3 votes

I'd change line 8 (approx) to:

def estimate = multiplier * (issue.getOriginalEstimate() ?: 0 ) / 3600

Your problem is the overloaded operator "*" can be applied to either Characters, Numbers or Strings etc, so if issue.originalEstimate is null groovy doesn't know which to pick.

The pitfalls of dynamic typing... 


Perfect, resolved issue

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Apr 10, 2018 in Marketplace Apps

Learn about how Stefan K. built one of the *first ever* Marketplace apps

In this post you will discover more about the evolution of K15t software, some big topics they're currently focusing on in the app space, and a rare (not not funny!) photo of founders Mike Cannon-Bro...

13,055 views 11 24
Read article

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