Apache Software Foundation / Maven Core
Merged upstreamCorrectnessMerged Aug 22, 2026

Fix concurrent updates to mapped model sources

Fixed Maven model-source indexing so concurrent model discovery cannot lose source entries when several tasks update the same mapped source bucket.

apache/maven · #12766

Problem

`mappedSources` used a ConcurrentHashMap for the outer map but stored ordinary HashSet values inside it. Parallel model discovery could concurrently mutate the same inner set and lose sources or expose unsafe iteration behavior.

Approach

Changed each mapped source set to `ConcurrentHashMap.newKeySet()`, preserving duplicate suppression while making concurrent updates and weakly consistent iteration safe, and added regression coverage for direct and secondary null-group source indexes.

Impact and scope

  • Hardens Maven 4 model discovery under parallel execution by removing a thread-unsafe collection from a concurrent data path.
  • Preserves existing deduplication and lookup semantics while making concurrent writes safe.
  • Adds focused regression tests around a core build-system path where lost model sources can affect dependency and reactor resolution.

Validation

  • Added concurrency-focused tests for concurrent writes, null-group index updates, lookup behavior, and duplicate suppression.
  • PR evidence reports `mvn -pl impl/maven-impl verify` with 552 tests passed and 4 skipped.
  • PR evidence also reports Java 21 Core IT execution with 1,051 integration tests run and targeted reruns for toolchain-sensitive classes.