Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Behaviour: formField.setFormValue causes java.lang.StackOverflowError Edited

Hello,

i am trying to set a formfield using a behaviour.

The data i am trying to set is read from another issue.

When i try to set the field value like this

Issue presetFound = (Issue) issueIterator.next()
Customfield field = customfieldManager.getCustomFieldObject(11603L)
java.lang.Object fieldValue = presetFound.getCustomFieldValue(field)
if (fieldValue != null) {
com.onresolve.jira.groovy.user.FormField formField = getFieldById(field.getId())
errorMessage += "set field " + field.getId() + " to " + fieldValue.toString() + ", field is " + formField.getClass().toString()
formField.setFormValue(fieldValue)
}

When i comment out the last statement the errorMessage is 

set field customfield_11700 to KLE-VE-4753 field is class com.onresolve.jira.groovy.user.FormField

When the statement is not uncommented the beheviour is not executed and this errror is logged:

2018-10-30 16:41:43,441 http-nio-8080-exec-79 ERROR admin 1001x12741x1 1s5x3j9 80.147.223.246,127.0.0.1 /rest/scriptrunner/behaviours/latest/runvalidator.json [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: null
java.lang.StackOverflowError
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaBeanProperty.getProperty(MetaBeanProperty.java:62)
at groovy.lang.PropertyValue.getValue(PropertyValue.java:42)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.getProperties(DefaultGroovyMethods.java:389)
at groovy.json.JsonOutput.getObjectProperties(JsonOutput.java:327)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:320)

See here for the Full Exception

1 answer

1 accepted

0 votes
Answer accepted

Hi @Jens Kisters _APTIS_,

your are add an Object to custom field and this cause the error. Please, could you verify what is the type of your custom field?

If it is a text, you need to add String as value, if it is a select list you need to add an Option and so on.

Great, that was exactly the problem.

Thanks a lot!

You're welcome Jens!

brbojorque Community Leader Dec 03, 2018

Hi Jens, can you provide the full working code?

Hi Bryan,

 

i have nothing i can quickly paste for you, but the working version should be something like this (3rd line is the one with the change):

 


Issue presetFound = (Issue) issueIterator.next()
Customfield field = customfieldManager.getCustomFieldObject(11603L)
String fieldValue = (String) presetFound.getCustomFieldValue(field)
if (fieldValue != null) {
com.onresolve.jira.groovy.user.FormField formField = getFieldById(field.getId())
errorMessage += "set field " + field.getId() + " to " + fieldValue.toString() + ", field is " + formField.getClass().toString()
formField.setFormValue(fieldValue)
}

Am I the only one left wondering why this causes a StackOverflowError?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Asked in Jira Service Desk

Calling all Insight users, we need your help!

Hello Insight users,  As part of our (Mindville's) acquisition by Atlassian, our training team is looking to build some new Insight training materials. It would really helpful if you can ...

135 views 1 0
View question

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you