ConcurrentModification exception on Java 8 for plugins.withId() with Gradle 2.4+

Using Gradle-2.4-20150408220020, also occurs with Gradle-2.5-20150413031218. Does not occur with Gradle 2.3.

Seems to be caused by calling hasPlugin() for most plugins from multiple plugins.withId{} blocks, occurs with both the PluginContainer and PluginManager APIs, and appears to only trigger when running Gradle with Java 8. Exception doesn’t occur until plugins are actually applied, and appears to be order-dependent, e.g. if ‘ivy-publish’ is applied first the exception doesn’t happen.

Example project here.

package com.example

import org.gradle.api.Plugin
import org.gradle.api.Project

class ExamplePlugin implements Plugin<Project> {
  void apply(final Project project) {
    project.plugins.withId('ivy-publish') {
      project.plugins.hasPlugin('jacoco')
    }
    //Works if:
    //this part is removed
    //or ivy-publish is applied before ExamplePlugin
    //or build with Java 7 instead of Java 8
    //or build with Gradle 2.3 instead of 2.4/2.5
    project.plugins.withId('maven-publish') {
      project.plugins.hasPlugin('jacoco')
    }
  }
}

Side note - the new forums appear to be unreasonably picky about thread titles - I had to deliberately obfuscate the title wording to get it to accept.

Thanks for the report, this has been fixed for 2.4.

Confirmed this is fixed in the more recent 2.4 snapshots, thanks!