maven-jar-plugin icon indicating copy to clipboard operation
maven-jar-plugin copied to clipboard

Race condition when two Jars being created at the same time

Open JasonMathison opened this issue 6 months ago • 0 comments

Affected version

3.4.2

Bug description

Sorry if am sending this bug report to the wrong place. While there are MJAR tickets in Jira, I couldn't create a ticket against that project, so sending it here.

We have been dealing with an intermittent problem where occasionally one of the jar files in our build would be non-functional. It turned out that the file was < 10KB, only containing the immediate project output, wtih no dependencies included.

It appears that this could be an issue with the maven JAR plugin when maven is run with -T 3

An example of the JAR file being correctly build looks like this: 09:00:55 [INFO] --- maven-jar-plugin:3.4.2:jar (default-jar) @ maestro-ocelot-log-level-lambda --- 09:00:55 [INFO] Building jar: /var/build/workspace/build-maestro/maestro-ocelot-log-level-lambda/target/maestro-ocelot-log-level-lambda.jar 09:00:55 [INFO] 09:00:55 [INFO] --- maven-shade-plugin:3.6.0:shade (default) @ maestro-ocelot-log-level-lambda --- 09:00:55 [INFO] 09:00:55 [INFO] ------------------------------------------------------- 09:00:55 [INFO] T E S T S 09:00:55 [INFO] ------------------------------------------------------- 09:00:55 [INFO] Including com.amazonaws:aws-lambda-java-core:jar:1.2.3 in the shaded jar.

followed by lots of shade output and a functional zip file of ~ 55 MBs.

An example of a build that results in a JAR file missing dependences looks like this:

0:35:26 [INFO] --- maven-jar-plugin:3.4.2:jar (default-jar) @ maestro-ocelot-log-level-lambda --- 10:35:26 [INFO] Building jar: /var/build/workspace/build-maestro/maestro-ocelot-log-level-lambda/target/maestro-ocelot-log-level-lambda.jar 10:35:26 [INFO] Building jar: /var/build/workspace/build-maestro/maestro-contracts/target/maestro-contracts-0.0.1.3455-tests.jar 10:35:26 [INFO] 10:35:26 [INFO] --- maven-shade-plugin:3.6.0:shade (default) @ maestro-ocelot-log-level-lambda --- 10:35:26 [INFO] 10:35:26 [INFO] --- maven-install-plugin:3.1.4:install-file (default) @ maestro-contracts --- 10:35:26 [INFO] No artifact matching filter net.logstash.logback:logstash-logback-encoder 10:35:26 [INFO] No artifact matching filter com.inin.messages:inin-messages-events 10:35:26 [INFO] Replacing original artifact with shaded artifact. 10:35:26 [INFO] Replacing /var/build/workspace/build-maestro/maestro-ocelot-log-level-lambda/target/maestro-ocelot-log-level-lambda.jar with /var/build/workspace/build-maestro/maestro-ocelot-log-level-lambda/target/maestro-ocelot-log-level-lambda-0.0.1.3455-shaded.jar

Notice that the shade plugin did not do any work, which I assume means that the JAR file didn't have any dependencies for it to clean up. The JAR file ended up being < 10 KBs.

I found three examples of this issue. Every time that the zip file did not contain any dependencies the log file showed that 2 JAR files were being generated at the same time.

Does this give enough to go on or would there be any tracing that I could enable to help troubleshoot this issue?

JasonMathison avatar Apr 22 '25 19:04 JasonMathison