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

Accepted Answer
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
Community showcase
Posted Oct 11, 2018 in Marketplace Apps

You + one app + a desert island...

Hi all! My name is Miles and I work on the Marketplace team. We’re looking for better ways to recommend and suggest apps that are truly crowd favorites, so of course we wanted to poll the Community. ...

3,335 views 6 6
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