Skip to content

Conversation

@dc-abuettgenbach
Copy link

Summary

This PR fixes the ConcurrentModificationException that occurs when running dependencyUpdates with Gradle 9.x and AGP 9.x.

Root Cause

When iterating over configurations using matching() or accessing buildscript.configurations, the returned collection is a live view that reflects changes to the underlying ConfigurationContainer.

With Gradle 9.x and AGP 9.x, configurations are created lazily during dependency resolution. This causes ConcurrentModificationException when the dependencyUpdates task iterates over configurations while resolution triggers lazy creation of new configurations.

The Fix

Add .toSet() to create a snapshot before iteration:

// Before (live view - causes CME)
it.configurations.matching(filterConfigurations)

// After (snapshot - safe to iterate)
it.configurations.matching(filterConfigurations).toSet()

Testing

Tested successfully with:

  • Gradle 9.2.1
  • AGP 9.0.0-rc01
  • Multi-module Android project with 15+ modules

Related Issues

Fixes #966
Related to #968 (configuration cache compatibility - separate issue)


🤖 Generated with Claude Code

…ionException

When iterating over configurations using `matching()` or accessing
`buildscript.configurations`, the returned collection is a live view
that reflects changes to the underlying ConfigurationContainer.

With Gradle 9.x and AGP 9.x, configurations are created lazily during
dependency resolution. This causes ConcurrentModificationException when
the `dependencyUpdates` task iterates over configurations while resolution
triggers lazy creation of new configurations.

The fix adds `.toSet()` to create a snapshot before iteration, ensuring
the collection remains stable during the resolution process.

Fixes ben-manes#966
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.

with gradle 9.0 no updates are shown

1 participant