Skip to content

Introduce unit tests at all, make one for ConcurrentModificationException [JENKINS-76294]#537

Open
jimklimov wants to merge 1 commit intojenkinsci:masterfrom
jimklimov:JENKINS-76294-CME-test
Open

Introduce unit tests at all, make one for ConcurrentModificationException [JENKINS-76294]#537
jimklimov wants to merge 1 commit intojenkinsci:masterfrom
jimklimov:JENKINS-76294-CME-test

Conversation

@jimklimov
Copy link

@jimklimov jimklimov commented Nov 27, 2025

Catching up for PR #536 and issue #336, here is a unit test that does reproduce the issue https://issues.jenkins.io/browse/JENKINS-76294 with current code base (at least it did fail on first try in my laptop).

This commit will be included into PR #536 to check whether(/that) it solves the problem.

Note that previously this repository had no tests, so relevant pom.xml bits were copied from Lockable Resource plugin (along with the convoluted test to force the race condition and crash the best we can). The pom.xml changes in particular may be a bit of overkill for this one test case, pulling in components that are not really referenced (I did not investigate deeper). They might be useful if someone adds other tests later though.

@jimklimov jimklimov requested a review from a team as a code owner November 27, 2025 15:08
@jimklimov
Copy link
Author

jimklimov commented Nov 27, 2025

Et voila, the test failed (in the expected manner exposing the original bug) with existing code base on Jenkins CI too: https://ci.jenkins.io/job/Plugins/job/cucumber-reports-plugin/job/PR-537/1/testReport/net.masterthought.jenkins/ConcurrentModificationExceptionTest/

...
[Pipeline] // parallel
[Pipeline] End of Pipeline
java.util.ConcurrentModificationException
 at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1606)
 at java.base/java.util.HashMap$EntryIterator.next(HashMap.java:1639)
 at java.base/java.util.HashMap$EntryIterator.next(HashMap.java:1637)
 at com.thoughtworks.xstream.converters.collections.MapConverter.marshal(MapConverter.java:76)
 at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68)
 at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
 at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:83)
 at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:283)
 at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:270)
Caused: java.lang.RuntimeException: Failed to serialize net.masterthought.jenkins.SafeArchiveServingAction#fileChecksums for class net.masterthought.jenkins.SafeArchiveServingRunAction
 at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:274)
 at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:241)
...
 at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:270)
Caused: java.lang.RuntimeException: Failed to serialize hudson.model.Actionable#actions for class org.jenkinsci.plugins.workflow.job.WorkflowRun
 at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:274)
...
 at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawSet(PropertyAccessBlock.java:24)
Also:   org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 15a2e417-669e-4315-ac70-71f41d25c318
Caused: java.io.IOException
 at hudson.XmlFile.write(XmlFile.java:223)
...
 at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawSet(PropertyAccessBlock.java:24)
 at WorkflowScript.run(WorkflowScript:29)
 at ___cps.transform___(Native Method)
 at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.set(PropertyishBlock.java:87)
...
 at java.base/java.lang.Thread.run(Thread.java:1474)
Finished: FAILURE

------

Expected: is <SUCCESS>
     but: was <FAILURE>
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.jvnet.hudson.test.JenkinsRule.assertBuildStatus(JenkinsRule.java:1463)
	at org.jvnet.hudson.test.JenkinsRule.assertBuildStatusSuccess(JenkinsRule.java:1491)
	at net.masterthought.jenkins.ConcurrentModificationExceptionTest.noCmeWhileSavingXStreamVsSafeArchiveServingRunAction(ConcurrentModificationExceptionTest.java:249)

…tion [JENKINS-76294]

Signed-off-by: Jim Klimov <jimklimov+jenkinsci@gmail.com>
@damianszczepanik
Copy link
Member

Did you review failing builds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants