-
Bug
-
Resolution: Fixed
-
Low
-
5.0.0, 9.0.0
-
None
-
1
-
Severity 3 - Minor
-
Issue Summary
Issue only occurs after Jira 9.x
When using Groovy scripts to update object attributes with unique values, if the script is ran multiple times in short period of time, there is an "ValidationInsightException" message.
This is reproducible on Data Center: yes
Steps to Reproduce
- Go to Administration > Manage Apps > Assets Script Console > and paste the following script:
import com.riadalabs.jira.plugins.insight.services.model.ObjectBean import com.atlassian.jira.component.ComponentAccessor; import org.apache.log4j.Logger import org.apache.log4j.Level Logger log = Logger.getLogger("test") log.setLevel(Level.ALL) void storeObjectAttributes(ObjectBean objectBean, Integer attributeId, String... values) { Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade"); def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass); Class objectTypeAttributeFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade"); def objectTypeAttributeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectTypeAttributeFacadeClass); Class objectAttributeBeanFactoryClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.services.model.factory.ObjectAttributeBeanFactory"); def objectAttributeBeanFactory = ComponentAccessor.getOSGiComponentInstanceOfType(objectAttributeBeanFactoryClass); log.info("Object: $objectBean") def objectTypeAttributeBean = objectTypeAttributeFacade.loadObjectTypeAttribute(attributeId).createMutable() log.info("\tobjectTypeAttributeBean: $objectTypeAttributeBean") def objectAttributeBean = objectFacade.loadObjectAttributeBean(objectBean.getId(), objectTypeAttributeBean.getId()) log.info("\tobjectAttributeBean: $objectAttributeBean") log.info("Value: $values") def newObjectAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(objectBean, objectTypeAttributeBean, values) if (objectAttributeBean != null) { newObjectAttributeBean.setId(objectAttributeBean.getId()) } objectFacade.storeObjectAttributeBean(newObjectAttributeBean) log.info("\tSuccess: Object updated") } storeObjectAttributes(object, 5, 10092 as String) storeObjectAttributes(object, 5, 10092 as String) //storeObjectAttributes(object, 5, 10092 as String) //storeObjectAttributes(object, 5, 10092 as String)
- You need to provide a valid Object Key in the Object Key field in Insight Script Console and pass appropriate input params attribute id and attribute value.
- Note: attribute that you update should have unique value constraint.
- In this example, attribute the attribute I want to updated has an attribute id 5 and it requires unique value.
- In "Object Key" field from the Groovy console, add the object to be updated
- While running the script, you could either invoke the function multiple times or click run button in script console multiple times to reproduce the issue.
Expected Results
Object should be updated without any error.
Actual Results
The below exception is thrown in the atlassian.log file:
2023-04-24 12:19:23,585+0000 http-nio-8080-exec-27 url: /rest/insight/1.0/groovy/evaluate; user: admin DEBUG admin 739x7793x2 6zkla5 xxxx /rest/insight/1.0/groovy/evaluate [c.r.j.p.i.services.validation.ValidateObjectImpl] Unique check: Concurrent modification occurred on attribute 5 2023-04-24 12:19:23,585+0000 http-nio-8080-exec-27 url: /rest/insight/1.0/groovy/evaluate; user: admin INFO admin 739x7793x2 6zkla5 xx /rest/insight/1.0/groovy/evaluate [c.r.j.p.i.services.util.ServiceUtil] InsightException:ValidationInsightException: Validation errors were found: rlabs-insight-attribute-5: ErrorMessage{i18nKey='rlabs.insight.i18n.constraint.violation.unique', parameters=[Worklog], additionalMessage=null}; com.riadalabs.jira.plugins.insight.common.exception.ValidationInsightException: ValidationInsightException: Validation errors were found: rlabs-insight-attribute-5: ErrorMessage{i18nKey='rlabs.insight.i18n.constraint.violation.unique', parameters=[Worklog], additionalMessage=null}; at com.riadalabs.jira.plugins.insight.services.validation.ValidateObjectImpl.validateObjectAttributeBean(ValidateObjectImpl.java:153) at com.riadalabs.jira.plugins.insight.services.core.ObjectServiceImpl.storeObjectAttribute(ObjectServiceImpl.java:1158) at com.riadalabs.jira.plugins.insight.channel.external.api.facade.impl.ObjectFacadeImpl.storeObjectAttributeBean(ObjectFacadeImpl.java:119) at com.riadalabs.jira.plugins.insight.channel.external.api.facade.impl.ObjectFacadeImpl.storeObjectAttributeBean(ObjectFacadeImpl.java:112) at com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade$storeObjectAttributeBean$0.call(Unknown Source) at Script1.storeObjectAttributes(Script1.groovy:30) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:169) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185) at Script1.run(Script1.groovy:37) {code}
Workaround
Currently there is no known workaround for this behavior. A workaround will be added here when available
- duplicates
-
JSDSERVER-14880 Updating a unique assets attribute value results in ValidationInsightException
-
- Closed
-
Form Name |
---|
[JSDSERVER-12676] ValidationInsightException when updating object attributes with unique values
Remote Link | New: This issue links to "Page (Confluence)" [ 859768 ] |
Link |
New:
This issue duplicates |
Comment |
[ Why is this Closed without a solution & not even a workaround??
Also this issue is observed in rest api calls to update the objects!! ] |
Remote Link | New: This issue links to "Page (Confluence)" [ 762277 ] |
Resolution | New: Fixed [ 1 ] | |
Status | Original: Waiting for Release [ 12075 ] | New: Closed [ 6 ] |
Fix Version/s | New: 5.4.7 [ 105290 ] | |
Fix Version/s | New: 5.9.0 [ 104928 ] | |
Fix Version/s | New: 5.8.1 [ 104917 ] |
Status | Original: In Progress [ 3 ] | New: Waiting for Release [ 12075 ] |
Support reference count | New: 1 |
Affects Version/s | New: 5.0.0 [ 99898 ] |
Status | Original: Needs Triage [ 10030 ] | New: In Progress [ 3 ] |