Skip to content

Enable Maven 4 build and fix IT failures#3402

Closed
gnodet wants to merge 1 commit into
masterfrom
quick-fix/maven4-enablement
Closed

Enable Maven 4 build and fix IT failures#3402
gnodet wants to merge 1 commit into
masterfrom
quick-fix/maven4-enablement

Conversation

@gnodet

@gnodet gnodet commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Enable Maven 4 in the CI matrix (maven4-enabled: true) with proper JDK 11 exclusion
  • Fix integration test failures caused by maven-verifier:2.0.0-M1 API incompatibility with Maven 4
  • Fix pre-existing race condition in CountdownCloseable

Details

Maven 4 CI matrix

The shared workflow's matrix uses the exact version string 4.0.0-rc-5, so the exclude must match it exactly (not just "4"). JDK 8 is already auto-excluded by the shared workflow when maven4-enabled=true.

IT failures — maven-verifier embedded mode

All integration tests fail with Maven 4 because maven-verifier:2.0.0-M1 uses reflection to call MavenCling.doMain(String[], String, PrintStream, PrintStream) in embedded mode, but Maven 4 rc-5 changed this method signature. The fix detects Maven 4 by checking for maven-cling-*.jar in the Maven home lib directory and forces forked JVM mode, bypassing the broken reflection entirely.

This is a short-term workaround. The long-term fix is to migrate from maven-verifier (which is being deprecated) to maven-executor (org.apache.maven.executor:maven-executor:1.0.0), which natively supports both Maven 3.x and 4.x.

CountdownCloseable race condition

CountdownCloseable.awaitClosed() used if instead of while to guard Object.wait(), making it vulnerable to spurious wakeups per the Java Language Specification. This is a pre-existing bug unrelated to Maven 4, but it could cause intermittent CommandlineExecutorTest failures under different JVM timing.

Related

Test plan

  • surefire-extensions-api unit tests pass locally (including CommandlineExecutorTest)
  • Full project builds successfully (mvn clean install -DskipTests)
  • CI: Maven 3.9.x cells should continue to pass (no behavior change)
  • CI: Maven 4 + JDK 17/21 cells should now pass with forked mode
  • CI: Maven 4 + JDK 8/11 cells should be excluded from the matrix

🤖 Generated with Claude Code

Enable Maven 4 in the CI matrix by setting maven4-enabled: true.
Exclude JDK 11 from Maven 4 cells since Maven 4 requires Java 17+
(JDK 8 is already auto-excluded by the shared workflow).

Force forked JVM mode in MavenLauncher when Maven 4 is detected,
working around maven-verifier 2.0.0-M1's broken embedded-mode
reflection against the changed MavenCling.doMain() signature in
Maven 4 rc-5. Detection checks for maven-cling-*.jar in the
Maven home lib directory. This workaround can be removed once
surefire migrates from maven-verifier to maven-executor.

Also fix a pre-existing race condition in CountdownCloseable where
awaitClosed() used 'if' instead of 'while' to guard Object.wait(),
making it vulnerable to spurious wakeups per the JLS.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet

gnodet commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of pushing directly to #3352's branch.

@gnodet gnodet closed this Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant