Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Versions Maven Plugin updates random Module subsets with 2.14.1 #858

Closed
jwachter opened this issue Dec 16, 2022 · 2 comments · Fixed by #859
Closed

Versions Maven Plugin updates random Module subsets with 2.14.1 #858

jwachter opened this issue Dec 16, 2022 · 2 comments · Fixed by #859
Labels
Milestone

Comments

@jwachter
Copy link

Environment

  • Maven Multimodule Project with 295 Modules in a strict parent-child hierarchy
  • Maven Wrapper using Maven 3.8.6
  • Calling mvnw.cmd or ./mvnw with versions:set -DnewVersion=1.2.3-SNAPSHOT -DgenerateBackupPoms=false

Observed Behavior

On multiple runs it is not deterministic which versions are updated:

  • Run 1: 135 of 295 are not updated after BUILD SUCCESS (All children of a sub-parent)
  • Run 2: 0 of 295 are not updated after BUILD SUCCESS
  • Run 3: 3 of 295 are not updated after BUILD SUCCESS
  • Run 4: 138 of 295 are not updated after BUILD SUCCESS (Children in multiple disjoint sub-parent hierarchies)

One of the sub parent hierarchies that seems to be always involved (partially) when something is not updated contains a single level of ~140 children but still not always only that hierarchy or a specific number of the children is affected.

With 2.14.0 it seems to not be broken yet for the same amount of test runs.

As this seems somewhat like a typical race condition we suspect that the introduction of parallelStream in this line combined with a non-concurrent Map might be problematic: c74ced2#diff-f58ee99d4e29219ee1519ba59712674919933915a6485ab987093718d0b773dbR1359

Expected Behavior

All modules are consistently updated.

@jarmoniuk
Copy link
Contributor

Thanks for the bug report. I think it's rather (files::add) which causes the problem in combination with parallelStream.

corebonts pushed a commit to corebonts/versions that referenced this issue Dec 16, 2022
Child modules were processed in a parallel stream which added elements to
an unsynchonized LinkedHashMap.

This may resulted an incomplete set of child modules.
corebonts pushed a commit to corebonts/versions that referenced this issue Dec 16, 2022
Child modules were processed in a parallel stream which added elements to
an unsynchonized LinkedHashMap.

This may resulted an incomplete set of child modules.
jarmoniuk added a commit to jarmoniuk/versions-maven-plugin that referenced this issue Dec 16, 2022
corebonts pushed a commit to corebonts/versions that referenced this issue Dec 16, 2022
Child modules were processed in a parallel stream which added elements to
an unsynchonized LinkedHashMap.

This may resulted an incomplete set of child modules.

Note that as the stream items are not processed heavily there is no or minor
advantage of parallel processing.
@jarmoniuk
Copy link
Contributor

@corebonts there's also https://github.com/mojohaus/versions/blob/master/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java#L375

here, the non-thread safe collection is modified from within a parallel stream

please add that to your branch if you want

corebonts pushed a commit to corebonts/versions that referenced this issue Dec 16, 2022
Modules were processed in a parallel stream which added elements to
an unsynchonized LinkedHashMap / LinkedHashSet.

This may resulted an incomplete set of child modules.

Note that as the stream items are not processed heavily there is no or minor
advantage of parallel processing.
@slawekjaranowski slawekjaranowski added this to the next-release milestone Dec 16, 2022
slawekjaranowski pushed a commit that referenced this issue Dec 16, 2022
Modules were processed in a parallel stream which added elements to
an unsynchonized LinkedHashMap / LinkedHashSet.

This may resulted an incomplete set of child modules.

Note that as the stream items are not processed heavily there is no or minor
advantage of parallel processing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants