rewrite icon indicating copy to clipboard operation
rewrite copied to clipboard

Allow configuration of HTTP timeouts for maven repositories

Open ammachado opened this issue 1 year ago • 3 comments

What's changed?

Changed maven downloader to allow configuration of connection/read timeouts

What's your motivation?

https://maven.apache.org/guides/mini/guide-http-settings.html#connection-timeouts

Anything in particular you'd like reviewers to focus on?

No

Anyone you would like to review specifically?

No

Have you considered any alternatives or workarounds?

No

Any additional context

N/A

Checklist

  • [x] I've added unit tests to cover both positive and negative cases
  • [x] I've read and applied the recipe conventions and best practices
  • [x] I've used the IntelliJ IDEA auto-formatter on affected files

ammachado avatar Jan 27 '24 04:01 ammachado

Nice addition @ammachado ! I'm tagging @sambsnyd for an additional review as we're adding fields to tree classes, and he reworked parts of the Maven repository handling recently.

Also copying the details on the failed test to save others a click

MavenPomDownloaderTest > centralIdOverridesDefaultRepository() FAILED
    java.lang.AssertionError: 
    Expecting elements:
      [MavenRepository(id=local, uri=file:///home/runner/.m2/repository, releases=true, snapshots=true, knownToExist=true, username=null, *** connectTimeout=null, readTimeout=null, deriveMetadataIfMissing=false),
        MavenRepository(id=central, uri=https://repo.maven.apache.org/maven2, releases=true, snapshots=false, knownToExist=true, username=null, *** connectTimeout=null, readTimeout=null, deriveMetadataIfMissing=true)]
    to be exactly 1 times URI https://internalartifactrepository.yourorg.com/
        at org.openrewrite.maven.internal.MavenPomDownloaderTest.centralIdOverridesDefaultRepository(MavenPomDownloaderTest.java:115)

timtebeek avatar Feb 01 '24 09:02 timtebeek

Nice addition @ammachado ! I'm tagging @sambsnyd for an additional review as we're adding fields to tree classes, and he reworked parts of the Maven repository handling recently.

Also copying the details on the failed test to save others a click

MavenPomDownloaderTest > centralIdOverridesDefaultRepository() FAILED
    java.lang.AssertionError: 
    Expecting elements:
      [MavenRepository(id=local, uri=file:///home/runner/.m2/repository, releases=true, snapshots=true, knownToExist=true, username=null, *** connectTimeout=null, readTimeout=null, deriveMetadataIfMissing=false),
        MavenRepository(id=central, uri=https://repo.maven.apache.org/maven2, releases=true, snapshots=false, knownToExist=true, username=null, *** connectTimeout=null, readTimeout=null, deriveMetadataIfMissing=true)]
    to be exactly 1 times URI https://internalartifactrepository.yourorg.com/
        at org.openrewrite.maven.internal.MavenPomDownloaderTest.centralIdOverridesDefaultRepository(MavenPomDownloaderTest.java:115)

As a suggestion, can you consider publishing the test reports on a failed build? Perhaps using a custom action for it (for example, https://github.com/marketplace/actions/junit-report-action).

ammachado avatar Feb 01 '24 13:02 ammachado

As a suggestion, can you consider publishing the test reports on a failed build? Perhaps using a custom action for it (for example, https://github.com/marketplace/actions/junit-report-action).

Yes I'd been eyeing https://github.com/gradle/actions/tree/main/setup-gradle#build-reporting earlier today, as part of our upgrade in https://github.com/openrewrite/gh-automation/ . It's been a pain point of mine as well to have to go into the logs.

timtebeek avatar Feb 01 '24 13:02 timtebeek

What's the motivation here? Does this solve a problem you are running into?

sambsnyd avatar Jun 13 '24 16:06 sambsnyd

Not my PR but I am watching as I also have an issue that would be solved with this.

During execution the plugin downloads maven-metadata.xml files. My company's internal proxy of Maven Central is very slow for downloads of these files. I cannot get the wider and obvious root cause fixed. The files do download eventually, however in the current implementation there is no way to set the timeout as the custom code to download the maven-metadata.xml files in the plugin does not respect the <configuration> declarations for a <server> specified here.

cjohnsto88 avatar Jun 17 '24 12:06 cjohnsto88

Not my PR but I am watching as I also have an issue that would be solved with this.

During execution the plugin downloads maven-metadata.xml files. My company's internal proxy of Maven Central is very slow for downloads of these files. I cannot get the wider and obvious root cause fixed. The files do download eventually, however in the current implementation there is no way to set the timeout as the custom code to download the maven-metadata.xml files in the plugin does not respect the <configuration> declarations for a <server> specified here.

That's exactly the issue that originated this change.

ammachado avatar Jun 17 '24 13:06 ammachado

Thanks a lot @ammachado ! Should help to conform to the user's configured session, as we've seen more variation in artifact repository performance than we had expected folks would tolerate in their day to day work. 🙃

timtebeek avatar Jun 19 '24 21:06 timtebeek