Concurrent Modification Exception occurs when using CamundaFormField method

Hello,

we have defined additional filters/options on form fields using our workflow namespace:

<bpmn:userTask completionQuantity="1" camunda:assignee="${requester}" id="Task_2"name="Third task">
  <bpmn:extensionElements>
    <camunda:formData>
      <camunda:formField id="Response" label="Response" type="string">
        <workflow:fieldFilter>
          <workflow:editable>true</workflow:editable>
          <workflow:included>true</workflow:included>
        </workflow:fieldFilter>
      </camunda:formField>
    </camunda:formData>
  </bpmn:extensionElements>
</bpmn:userTask>

In the application we are processing the filters with the following code:

CamundaFormData camundaFormData = (CamundaFormData) userTask.getExtensionElements().getUniqueChildElementByNameNs("http://camunda.org/schema/1.0/bpmn", "formData");
CamundaFormField camundaFormField = camundaFormData.getCamundaFormFields().stream().filter(field->field.getCamundaId().equals("Response")).findFirst().get();
ModelElementInstance filters = camundaFormField.getUniqueChildElementByNameNs("http://example.com/schema/1.0/workflow", "fieldFilter");

In general, this works fine. However, in production we sometimes see the following error logs:

java.util.ConcurrentModificationException: null
    at java.util.ArrayList$Itr.checkForComodification
    at java.util.ArrayList$Itr.next
    at org.camunda.bpm.model.xml.impl.ModelBuilderImpl.build(ModelBuilderImpl.java:75)
    at org.camunda.bpm.model.xml.impl.ModelInstanceImpl.registerGenericType(ModelInstanceImpl.java:111)
    at org.camunda.bpm.model.xml.impl.util.ModelUtil.getModelElement(ModelUtil.java:91)
    at org.camunda.bpm.model.xml.impl.util.ModelUtil.getModelElement(ModelUtil.java:52)
    at org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl.getUniqueChildElementByNameNs(ModelElementInstanceImpl.java:192)
    at com.example.workflow.WorkflowFormFieldCamunda.getFilters(WorkflowFormFieldCamunda.java:142)

Any ideas why the CamundaFormField.getUniqueChildElementByNameNs() is throwing a java.util.ConcurrentModificationException? Usually this error occurs if a list is modified during iteration. Is it possible that there is a problem with the implementation?

1 Like

We have a similar issue that happens from time to time (not regulary):

Caused by: java.util.ConcurrentModificationException: null
	at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909) ~[na:1.8.0_251]
	at java.util.ArrayList$Itr.next(ArrayList.java:859) ~[na:1.8.0_251]
	at org.camunda.bpm.model.xml.impl.ModelBuilderImpl.build(ModelBuilderImpl.java:72) ~[camunda-xml-model-7.13.0.jar:7.13.0]
	at org.camunda.bpm.model.xml.impl.ModelInstanceImpl.registerGenericType(ModelInstanceImpl.java:111) ~[camunda-xml-model-7.13.0.jar:7.13.0]

Version: 7.13.0

It would be great if it’s resolved.