FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Upgrading Maven library to 3.9.9 by suztomo · Pull Request #2406 · GoogleCloudPlatform/cloud-opensource-java · GitHub

Upgrading Maven library to 3.9.9 - #2406

Open
suztomo wants to merge 3 commits into
masterfrom
maven_3.9.9
Open

Upgrading Maven library to 3.9.9#2406
suztomo wants to merge 3 commits into
masterfrom
maven_3.9.9

Conversation

suztomo commented Jun 6, 2025
edited
Loading

Copy link
Copy Markdown
Contributor

I tried to upgrade the Maven library version to 3.9.9. However, it fails with the RepositorySystem instance creation:

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.123 s <<< FAILURE! - in com.google.cloud.tools.opensource.classpath.ClassPathBuilderTest
[ERROR] testBomToPaths_firstElementsAreBomMembers(com.google.cloud.tools.opensource.classpath.ClassPathBuilderTest)  Time elapsed: 0.081 s  <<< ERROR!
java.lang.ExceptionInInitializerError
	at com.google.cloud.tools.opensource.classpath.ClassPathBuilderTest.<init>(ClassPathBuilderTest.java:42)
Caused by: com.google.common.base.VerifyException: Couldn't retrieve RepositorySystem
	at com.google.cloud.tools.opensource.classpath.ClassPathBuilderTest.<init>(ClassPathBuilderTest.java:42)

In this pull request, I added Verify.verifyNotNull(system, "Couldn't retrieve RepositorySystem"); to make the failure point clear (before this, it was failing a generic NullPointerException without a specific line number).

  /**
   * Creates a new system configured for file and HTTP repository resolution.
   */
  public static RepositorySystem newRepositorySystem() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
    RepositorySystem system = locator.getService(RepositorySystem.class);
    Verify.verifyNotNull(system, "Couldn't retrieve RepositorySystem");
    return system;
  }

The release note (https://maven.apache.org/docs/3.9.9/release-notes.html) says:

Mojos are prevented to bootstrap new instance of RepositorySystem (for example by using deprecated ServiceLocator), they should reuse RepositorySystem instance provided by Maven instead. See MNG-7471.

(3.9.0 release note also includes this)

Memo:

When the problem only happens in mvn command and not in IntelliJ, having JUnit waiting for debugger is helpful: ./mvnw test -Dtest="ClassPathBuilderTest#testBomToPaths_firstElementsAreBomMembers" -Dmaven.surefire.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005

b/416442478

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL