Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Behaviour: formField.setFormValue causes java.lang.StackOverflowError

Jens Kisters __SeibertSolutions
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.
October 30, 2018

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

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Fabio Racobaldo _Herzum_
Community Champion
October 30, 2018

Hi @Jens Kisters __SeibertSolutions,

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.

Jens Kisters __SeibertSolutions
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.
October 31, 2018

Great, that was exactly the problem.

Thanks a lot!

Fabio Racobaldo _Herzum_
Community Champion
October 31, 2018

You're welcome Jens!

brbojorque
Community Champion
December 3, 2018

Hi Jens, can you provide the full working code?

Jens Kisters __SeibertSolutions
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.
December 4, 2018

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)
}
Luis Muniz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 17, 2019

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

Like Marko Slijepčević likes this
TAGS
AUG Leaders

Atlassian Community Events