GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — MavenProject.getArtifacts() publishes a half-built set under concurrent access · Issue #13200 · apache/maven

MavenProject.getArtifacts() publishes a half-built set under concurrent access #13200

New issue
Copy link
New issue
Copy link
Closed
#13201
Closed
MavenProject.getArtifacts() publishes a half-built set under concurrent access#13200
#13201
Copy link
Labels
bugSomething isn't working

Description

@slachiewicz
slachiewicz
opened on Sep 19, 2026
Issue body actions

Affected version

3.9.x and master (same code on both).

Bug description

MavenProject.getArtifacts() initialises its set lazily and assigns the field before filling it:

artifacts = new LinkedHashSet<>(resolvedArtifacts.size() * 2);
for (Artifact artifact : resolvedArtifacts) {
    if (artifactFilter.include(artifact)) {
        artifacts.add(artifact);
    }
}

(maven-3.9.x MavenProject.java:675, master MavenProject.java:897)

A second thread calling getArtifacts() during the loop receives the half-built set and any iteration over it throws ConcurrentModificationException while the first thread keeps adding. The MojoExecutor project and aggregator locks keep mojo executions apart, so in a plain build the two callers should not overlap; the trace in apache/maven-plugin-tools#852 (maven-plugin-plugin:descriptor on a parallel build, LinkedHashMap$LinkedHashIterator.nextNode under JavaAnnotationsMojoDescriptorExtractor.extendJavaProjectBuilder) shows that something does overlap. The trigger there is not identified; the publication itself is unsafe regardless.

Fill a local set and assign it once, so a concurrent reader sees either null handling or a complete set:

Set<Artifact> result = new LinkedHashSet<>(...);
for (...) { ... result.add(artifact); }
artifacts = result;

The same pattern exists in getArtifactMap() / getDependencyArtifacts() and is worth the same treatment.

Activity

  1. slachiewicz
    added
    bugSomething isn't working
    on Sep 19, 2026
  2. gnodet
    closed this as completedin #13201on Sep 19, 2026
  3. pull
    added a commit that references this issue on Sep 19, 2026

    Fix apache#13200: publish a complete set from MavenProject.getArtifacts

    This issue will close once commit ab67bf7 is merged into the 'master' branch.
    ab67bf7
  4. gnodet
    added 2 commits that reference this issue on Sep 19, 2026

    Fix #13200: publish a complete set from MavenProject.getArtifacts

    This issue will close once commit 7d617c4 is merged into the 'master' branch.
    7d617c4

    Fix #13200: publish a complete set from MavenProject.getArtifacts

    This issue will close once commit 9a2aa9b is merged into the 'master' branch.
    9a2aa9b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.