Conversation
The -javaagent argument added in google#1483 is set per module as -javaagent:${org.mockito:mockito-core:jar} without quotes. Surefire splits argLine into JVM arguments at unquoted whitespace, so when the local Maven repository path contains a space (for example a Windows user profile such as C:\Users\First Last) the forked JVM receives a truncated agent path and exits before running any test: Error opening zip file or JAR manifest missing : C:\Users\First Quote the value in every module that sets it, which is how jacoco-maven-plugin already passes its own agent argument when the path contains a space, and note in the parent pom that the quotes must stay. CI runs on Ubuntu with a space-free repository path, so it could not catch this.
8 of 10 tasks
Contributor
|
Hi @innoprej, We greatly appreciate your contribution and the effort you put into this pull request. It is currently under review by our team. We will notify you if any additional details are needed. Thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
build: load Mockito as a startup Java agent for surefire tests)2. Or, if no issue exists, describe the change:
Problem:
Since #1483, every module whose tests use Mockito sets
mockito.javaagent.argto-javaagent:${org.mockito:mockito-core:jar}, and the parent pom prepends it to the surefireargLine. The value is not quoted. Surefire splitsargLineinto JVM arguments at unquoted whitespace, so when the local Maven repository path contains a space (for example a Windows user profile such asC:\Users\First Last\.m2\repository) the agent path is cut at the space and the forked JVM exits before running a single test:The JaCoCo agent argument in the same
argLineis not affected becausejacoco-maven-pluginquotes its own argument when the path contains a space. CI runs on Ubuntu with a space-free repository path, so it cannot see this.Solution:
Quote the value in the seven modules that set it (
a2a,core,dev,contrib/firestore-session-service,contrib/langchain4j,contrib/planners,contrib/spring-ai), which is the form the parent pom's comment already shows, and add a sentence to that comment saying the quotes must stay. The quotes belong in the value rather than around${mockito.javaagent.arg}in the parent'ssurefire.argLine:contrib/firestore-session-servicesplices the property into its ownargLine, so a parent-level change would not reach it, and a value that carries its own quotes works for every consumer, the same way the JaCoCo property does. No other build change.Testing Plan
Unit Tests:
Windows 11, Microsoft OpenJDK 17.0.19, Maven 4.0.0-rc-3 via
mvnw, with the local repository under a user profile path that contains a space unless noted:mainmvn -pl core test -Dtest=ToolConfirmationTestmvn -pl a2a test -Dtest=EventConverterTestmvn -pl contrib/firestore-session-service test -Dtest=FirestoreMemoryServiceTest(module with its ownargLine)mvn -pl core testargLineas above)LocalSkillSourceTest.testListResources, which fails the same way onmainwith a space-free repository pathmvn -pl core test -Dtest=ToolConfirmationTestwith a space-free repository pathThe same comparison also ran on GitHub-hosted runners in my fork (run), with
-Dmaven.repo.localpointing at a directory whose path contains spaces:main(-pl core -Dtest=ToolConfirmationTest)ubuntu-latest... missing : /home/runner/work/_temp/m2), 0 testswindows-latest... missing : D:\a\_temp\m2), 0 testsmacos-latest... missing : /Users/runner/work/_temp/m2), 0 testsThe same run also executed the
validationworkflow's command (./mvnw -Prelease clean package, thengit diff --exit-code) on this change with JDK 17, 21 and 25; all three passed.With
mvn -X, the forked command line now carries the agent as one quoted argument, next to the JaCoCo one:Manual End-to-End (E2E) Tests:
On Windows with a user profile path that contains a space, run
./mvnw -pl core test -Dtest=ToolConfirmationTestonmain: the surefire fork fails with the error above and no test runs. With this change the same command runs the tests, and the forked command line shows the agent as a single quoted argument, like the JaCoCo one next to it. On Linux and macOS the same happens with-Dmaven.repo.localset to a path with spaces (see the fork run above). IntelliJ's own test runner was not tried.Checklist
Additional context
Found while running the
coretests on Windows for #1534. The remaining Windows-only test failure (LocalSkillSourceTest.testListResources, which compares\with/) is unrelated and left for a separate change.