sonatype / install4j-support

Install4j Support
http://sonatype.github.io/install4j-support/
11 stars 11 forks source link

install4j-maven-plugin is not thread-safe #31

Open lasselindqvist opened 5 years ago

lasselindqvist commented 5 years ago

AntHelper.java seems to use outputstreams in such a way that the outputs might get mixed up with outputs from other running tasks.

This becomes a problem when trying to run the plugin as part of a multithreaded Maven build. It might fail to:

[2019-04-25T10:16:52.515Z] [ERROR] Failed to execute goal org.sonatype.install4j:install4j-maven-plugin:1.0.8:compile (compile-installers) on project install4j: Unable to parse version from input: Picked up JAVA_TOOL_OPTIONS: -Dmaven.ext.class.path="pipeline-maven-spy.jar" -Dorg.jenkinsci.plugins.pipeline.maven.reportsFolder="withMavene6640721" install4j version 6.1.2 (build 6275), built on 2016-06-21 -> [Help 1]

The Exception is thrown here: https://github.com/sonatype/install4j-support/blob/master/install4j-maven-plugin/src/main/java/org/sonatype/install4j/maven/VersionHelper.java#L87 and if I understand correctly, the root of the problem is AntHelper https://github.com/sonatype/install4j-support/blob/master/install4j-maven-plugin/src/main/java/org/sonatype/install4j/maven/AntHelper.java#L64

It seems to me that MavenAntLoggerAdapter is used and the output of calls is redirected to standard output where it mingles with other texts failing the version parsing.

Maybe the output could be redirected to a temporary file and read from there or fixed in some other way?

rkohser commented 3 years ago

Hi, I am running into the same issue with some race condition preventing compilation some times. Have you found a workaround ?

lasselindqvist commented 3 years ago

I have actually done a workaround in a private fork. It uses a temp file to write the version. But honestly the whole check is unnecessarily and could be removed (https://github.com/sonatype/install4j-support/blob/2ef000a45149902f92e3ecd68df1f5eeff437776/install4j-maven-plugin/src/main/java/org/sonatype/install4j/maven/Install4jcMojoSupport.java#L92) if you just trust that you have the necessary version.