ConcurrentModificationException during CpsThreadGroup.saveProgram

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ConcurrentModificationException during CpsThreadGroup.saveProgram

Ulli Hafner
I sometimes get in my integration tests of pipeline builds with my warnings steps a ConcurrentModificationException during CpsThreadGroup.saveProgram.

How can this happen? Do I need to take care of synchronization somewhere?

an exception which occurred:
        in field edu.hm.hafner.analysis.Report.infoMessages
        in object edu.hm.hafner.analysis.Report@105859bf
        in field io.jenkins.plugins.analysis.core.steps.AnnotatedReport.aggregatedReport
        in object io.jenkins.plugins.analysis.core.steps.AnnotatedReport@274c5b82
        in field io.jenkins.plugins.analysis.core.steps.PublishIssuesStep$Execution.report
        in object io.jenkins.plugins.analysis.core.steps.PublishIssuesStep$Execution@25f0dc81
        in field org.jenkinsci.plugins.workflow.cps.CpsThread.step
        in object org.jenkinsci.plugins.workflow.cps.CpsThread@7cf8c376
        in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.threads
        in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@9df7d3c
        in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@9df7d3c
Caused: java.util.ConcurrentModificationException
        at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909)
        at java.util.ArrayList$Itr.next(ArrayList.java:859)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:568)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
        at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
        at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
        at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
        at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
        at java.util.TreeMap.writeObject(TreeMap.java:2438)
        at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:273)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
        at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
        at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)
        at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)
        at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:140)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:459)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:435)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgramIfPossible(CpsThreadGroup.java:423)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:363)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:243)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:231)
        at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
        at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/ED08FA08-B26A-40AC-B3A8-FB4CD5CEB2EA%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ConcurrentModificationException during CpsThreadGroup.saveProgram

Jesse Glick-4
Do you have some background thread writing to `infoMessages` perhaps?

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3gv6d5ce_ZYr9dVpMGn%3Dij%3DAsn7RZEcX8Q0LYOX162CA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ConcurrentModificationException during CpsThreadGroup.saveProgram

Ulli Hafner

I'm not aware of any. When is CpsThreadGroup.saveProgram called? During execution of SynchronousNonBlockingStepExecution.run() ?
Should members of a  SynchronousNonBlockingStepExecution be constant?

Am Donnerstag, 15. November 2018 23:25:01 UTC+1 schrieb Jesse Glick:
Do you have some background thread writing to `infoMessages` perhaps?

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/4383cb34-1ac7-4dc2-9e5b-70571ca9f5dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ConcurrentModificationException during CpsThreadGroup.saveProgram

Jesse Glick-4
Am Donnerstag, 15. November 2018 23:25:01 UTC+1 schrieb Jesse Glick:
>> Do you have some background thread writing to `infoMessages` perhaps?

On Fri, Feb 8, 2019 at 9:28 AM Ullrich Hafner <[hidden email]> wrote:
> I'm not aware of any.

Trying wrapping all field accessors in `Collections.immutableList` and
you will find out fast!

> When is CpsThreadGroup.saveProgram called?

At various times, though always within the CPS VM thread.

> During execution of SynchronousNonBlockingStepExecution.run() ?

Not from that thread.

> Should members of a  SynchronousNonBlockingStepExecution be constant?

They need not be; if you need to mutate anything, use

https://javadoc.jenkins.io/plugin/workflow-step-api/org/jenkinsci/plugins/workflow/steps/StepContext.html#saveState--

But you do need to consider that the CPS VM thread may be _reading_
that state, so you may consider replacing `ArrayList` with
`CopyOnWriteList` for example.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr0KTq5uE5ThePSCGCy79QYUaqGwSA3PMpMDNcS5nOr1AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.