Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-27603

ConcurrentModificationException when running seed job

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • job-dsl-plugin
    • None
    • Job DSL Plugin 1.25

      Under some circumstances, the seed job fails with a ConcurrentModificationException.

      java.util.ConcurrentModificationException
              at java.util.HashMap$HashIterator.nextEntry(HashMap.java:922)
              at java.util.HashMap$KeyIterator.next(HashMap.java:956)
              at com.google.common.collect.AbstractMapBasedMultimap$WrappedCollection$WrappedIterator.next(AbstractMapBasedMultimap.java:484)
              at com.google.common.collect.Iterators$7.computeNext(Iterators.java:701)
              at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
              at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
              at com.google.common.collect.Sets.removeAllImpl(Sets.java:1598)
              at com.google.common.collect.Sets.removeAllImpl(Sets.java:1627)
              at com.google.common.collect.AbstractMapBasedMultimap$WrappedSet.removeAll(AbstractMapBasedMultimap.java:614)
              at javaposse.jobdsl.plugin.ExecuteDslScripts.updateTemplates(ExecuteDslScripts.java:226)
              at javaposse.jobdsl.plugin.ExecuteDslScripts.perform(ExecuteDslScripts.java:183)
              at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
              at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:772)
              at hudson.model.Build$BuildExecution.build(Build.java:199)
              at hudson.model.Build$BuildExecution.doRun(Build.java:160)
              at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:535)
              at hudson.model.Run.execute(Run.java:1732)
              at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
              at hudson.model.ResourceController.execute(ResourceController.java:88)
              at hudson.model.Executor.run(Executor.java:234)
      

          [JENKINS-27603] ConcurrentModificationException when running seed job

          Neil Hunt added a comment -

          +1

          Neil Hunt added a comment - +1

          Hello,
          I'm running in that problem as well. I'm running on Jenkins 1.595 / Job DSL 1.28
          I've narrowed it down to a DSL like this:
          When I un-comment the mavenOpts the plugin will fail with the ConcurrentModificationException
          {{
          job(type : 'maven') {
          name('XXXXXXXXXXXXXXXX');
          configure { project ->
          project / publishers / 'hudson.plugins.sonar.SonarPublisher'(plugin: 'sonar@2.1') <<

          { //mavenOpts('-Xmx1024m -Xms128m -XX:MaxPermSize=256m'); settings(class:'jenkins.mvn.DefaultSettingsProvider'); globalSettings(class:'jenkins.mvn.DefaultGlobalSettingsProvider'); }

          ;
          }
          }}}

          => I'll try to update to DSL 1.30

          Julien Masnada added a comment - Hello, I'm running in that problem as well. I'm running on Jenkins 1.595 / Job DSL 1.28 I've narrowed it down to a DSL like this: When I un-comment the mavenOpts the plugin will fail with the ConcurrentModificationException {{ job(type : 'maven') { name('XXXXXXXXXXXXXXXX'); configure { project -> project / publishers / 'hudson.plugins.sonar.SonarPublisher'(plugin: 'sonar@2.1') << { //mavenOpts('-Xmx1024m -Xms128m -XX:MaxPermSize=256m'); settings(class:'jenkins.mvn.DefaultSettingsProvider'); globalSettings(class:'jenkins.mvn.DefaultGlobalSettingsProvider'); } ; } }}} => I'll try to update to DSL 1.30

          jfjmasnada that's a different problem. You get the ConcurrentModificationException because you are unintentionally calling the mavenOpts DSL method from within a configure block. To fix that, you need to use the closure delegate for creating elements where the name collides with DSL method names:

          job(type : 'maven') {
              name('XXXXXXXXXXXXXXXX')
              configure { project ->
                  project / publishers << 'hudson.plugins.sonar.SonarPublisher' {
                      delegate.mavenOpts('-Xmx1024m -Xms128m -XX:MaxPermSize=256m')
                  }
              }
          }
          

          Daniel Spilker added a comment - jfjmasnada that's a different problem. You get the ConcurrentModificationException because you are unintentionally calling the mavenOpts DSL method from within a configure block. To fix that, you need to use the closure delegate for creating elements where the name collides with DSL method names: job(type : 'maven' ) { name( 'XXXXXXXXXXXXXXXX' ) configure { project -> project / publishers << 'hudson.plugins.sonar.SonarPublisher' { delegate.mavenOpts( '-Xmx1024m -Xms128m -XX:MaxPermSize=256m' ) } } }

          Another occurrence of this problem: https://github.com/jenkinsci/job-dsl-plugin/pull/592

          Daniel Spilker added a comment - Another occurrence of this problem: https://github.com/jenkinsci/job-dsl-plugin/pull/592

            jamietanna Jamie Tanna
            daspilker Daniel Spilker
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: