Skip to content

[maven-4.0.x] DefaultProjectBuildingHelper: synchronized bottleneck in parallel builds #12605

Description

@elharo

DefaultProjectBuildingHelper: Synchronized bottleneck in parallel builds

Found in: maven-4.0.x branch
File: impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java (line 117)
Severity: Medium

Description

The entire createProjectRealm() method is synchronized, making it a global lock during multi-module parallel builds:

@Override
public synchronized ProjectRealmCache.CacheRecord createProjectRealm(
        MavenProject project, Model model, ProjectBuildingRequest request)

During a multi-module build where many projects need extension realms set up concurrently, each must acquire this lock serially. Since the inner projectRealmCache uses ConcurrentHashMap and is already thread-safe, the synchronization could be narrowed to just the non-thread-safe portions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions