maven-wrapper icon indicating copy to clipboard operation
maven-wrapper copied to clipboard

[MWRAPPER-91] Concurrent execution of mvnw to download wrapper fails

Open jira-importer opened this issue 2 years ago • 3 comments

Alexander Schwartz opened MWRAPPER-91 and commented

The script will download the executable maven wrapper JAR file directly to the final file name. When multiple calls do this concurrently, it happens that the first call executes the JAR file that is currently overwritten by the second parallel call.

This leads to error like:

  • NoClassDefFoundError: org/codehaus/plexus/PlexusContainer
  • ClassNotFoundException: org.apache.maven.wrapper.MavenWrapperMain

A different solution might be to first download the JAR file to a temporary file, and then use an atomic file operator like a rename once the download is complete.


Affects: 3.1.0

Remote Links:

1 votes, 5 watchers

jira-importer avatar Jan 16 '23 07:01 jira-importer

Michael Osipov commented

Tamas Cservenak, I can't stop laughing because I knew that this Maven Wrapper will just cause work for very little benefit...

jira-importer avatar Jan 16 '23 08:01 jira-importer

Benjamin Marwell commented

Alexander Schwartz do you, by chance, know which scripts are affected? We have multiple wrappers, the "most modern" option at the moment being only-mvnw, See the "without binary" section here: https://maven.apache.org/wrapper/index.html

jira-importer avatar Feb 09 '24 15:02 jira-importer

Alexander Schwartz commented

Hi, at that time, we used mvnw with the script that then downloaded the JAR file of the wrapper as we didn't commit that to our repo. At the time, I didn't know about the script-only wrapper.

I migrated one of the projects I'm working for to the shell-only wrapper and it resolved for me the issue where MAVEN_ARGS where not supported by the other option - see MWRAPPER-110

I suppose the only-mvnw has a similar problem as it is writing directly to the file, instead of first downloading the file and then moving the file to the to final name after a successful download, see https://github.com/apache/maven-wrapper/blob/master/maven-wrapper-distribution/src/resources/only-mvnw#L202

jira-importer avatar Feb 10 '24 13:02 jira-importer