From 2cad307a05409071b9fa6589f09e1d55221d15a0 Mon Sep 17 00:00:00 2001 From: Hitesh Date: Thu, 25 Jun 2026 12:57:04 +0530 Subject: [PATCH 1/2] [MNG-11449] Fix Mockito agent: use late binding @{} interpolation and extend to failsafe plugin The mockito profile activated by dependency:properties used Maven property interpolation (\) which resolves at POM parse time - before the dependency:properties goal runs and sets the org.mockito:mockito-core:jar property. This caused the javaagent path to remain unresolved. Fix: use Surefire/Failsafe late-binding property interpolation (@{...}) which resolves the property at test execution time, after dependency:properties has already set it. Also: - Restore @{jacocoArgLine} placeholder (was dropped in previous attempt) - Extend the profile to cover maven-failsafe-plugin as well Fixes: https://issues.apache.org/jira/browse/MNG-11449 --- pom.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d83ddb44cb59..606c37dc2cfa 100644 --- a/pom.xml +++ b/pom.xml @@ -952,7 +952,14 @@ under the License. org.apache.maven.plugins maven-surefire-plugin - -Xmx256m -javaagent:${org.mockito:mockito-core:jar} + -Xmx256m @{jacocoArgLine} -javaagent:@{org.mockito:mockito-core:jar} + + + + org.apache.maven.plugins + maven-failsafe-plugin + + -Xmx256m @{jacocoArgLine} -javaagent:@{org.mockito:mockito-core:jar} From 2db4fbbeb99f646db40715d60677def187989a7e Mon Sep 17 00:00:00 2001 From: Hitesh Date: Fri, 26 Jun 2026 22:08:28 +0530 Subject: [PATCH 2/2] [MNG-11449] Fix Mockito agent profile collision with JaCoCo profile When both jacoco and mockito profiles were active, the jacoco profile's surefire configuration overrode the mockito profile's surefire pluginManagement configuration. This caused the mockito javaagent to be silently dropped for unit tests. Fix: Refactor the surefire and failsafe argLine to be composed dynamically via properties: - Define argLine.xmx (default: -Xmx256m) and argLine.mockito (default: empty) in the root POM properties. - Update default pluginManagement configuration for surefire/failsafe to: \ @{jacocoArgLine} \ - Modify the mockito profile to only set argLine.mockito property to the mockito javaagent. - Modify the jacoco profile to only override argLine.xmx property to -Xmx1G and remove the direct surefire argLine override. This ensures both profiles can be active simultaneously without overriding each other's configurations. --- pom.xml | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/pom.xml b/pom.xml index 606c37dc2cfa..775d7203aa2a 100644 --- a/pom.xml +++ b/pom.xml @@ -172,6 +172,8 @@ under the License. 7.2.1 2.12.0 + -Xmx256m + 0.14.1 @@ -697,7 +699,7 @@ under the License. maven-surefire-plugin - -Xmx256m @{jacocoArgLine} + ${argLine.xmx} @{jacocoArgLine} ${argLine.mockito} ${toolboxVersion} @@ -708,7 +710,7 @@ under the License. maven-failsafe-plugin - -Xmx256m @{jacocoArgLine} + ${argLine.xmx} @{jacocoArgLine} ${argLine.mockito} ${toolboxVersion} @@ -945,26 +947,9 @@ under the License. org.mockito:mockito-core:jar - - - - - org.apache.maven.plugins - maven-surefire-plugin - - -Xmx256m @{jacocoArgLine} -javaagent:@{org.mockito:mockito-core:jar} - - - - org.apache.maven.plugins - maven-failsafe-plugin - - -Xmx256m @{jacocoArgLine} -javaagent:@{org.mockito:mockito-core:jar} - - - - - + + -javaagent:@{org.mockito:mockito-core:jar} + graph @@ -1218,13 +1203,15 @@ under the License. jacoco + + -Xmx1G + org.apache.maven.plugins maven-surefire-plugin - -Xmx1G @{jacocoArgLine} ${project.build.directory}/test-results-surefire