Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cycle in problem reporter with unreachable artifacts. #6197

Merged
merged 2 commits into from
Jul 17, 2023

Conversation

sdedic
Copy link
Member

@sdedic sdedic commented Jul 14, 2023

There was a bug in the loop that causes the values NOT to be cached when the loop exited unsuccessfully, so the detection happened over and over again - computation intensive. This PR makes just one repeated attempt to resolve the artifacts, then reports whatever results are computed.

The reported error was made possible also because simple file-exists check is not enough: in the situation described by #6176, the artifact file physically exists locally (so priming detection evaluated that as an inconsistency and looped again), but is actually refused by Maven, as it is recorded to belong to a remote repository, but was never downloaded from there. The changes to MavenEmbedder use EnhancedLocalRepository that checks that thoroughly (the same way as Maven does during build). In addition MavenEmbedder.resolve() method never threw exceptions declared in the signature: partly they were swallowed by Maven library (in DefaultArtifactResolver) and partially they were ignored if present in result.getExceptions() - this affected existing clients that do exception hadling.

@sdedic sdedic added Maven [ci] enable "build tools" tests VSCode Extension [ci] enable VSCode Extension tests labels Jul 14, 2023
@sdedic sdedic added this to the NB19 milestone Jul 14, 2023
@sdedic sdedic self-assigned this Jul 14, 2023
@sdedic
Copy link
Member Author

sdedic commented Jul 14, 2023

The ProblemReporterImpl commit alone is suffcient to fix #6176.

I am a little nervous about the SimpleLocalRepository > EnhancedLocalRepository change as it might affect different operations in Maven; but unless this is used, the MavenEmbedder.resolve() will be satisifed with the locally existing artifact (although never downloaded from an unreachable repo) and will not report errors.

If some problems arise, this 2nd commit could be safely reverted - resulting in 2nd cycle in ProblemReporterImpl.

@sdedic sdedic linked an issue Jul 14, 2023 that may be closed by this pull request
1 task
@sdedic sdedic added the Regression This used to work! label Jul 14, 2023
@mbien
Copy link
Member

mbien commented Jul 14, 2023

the second commit appears to be the cause of the test failures.

I ran a quick local test and they appear to pass using only the first commit.

@matthiasblaesing
Copy link
Contributor

Tested with the original problematic maven project and the constructed testcase from the issue and seems to work as it should. Thank you.

@sdedic
Copy link
Member Author

sdedic commented Jul 14, 2023

I'll take care of the tests tomorrow / till Monday. Either adapt code (tests) to the suddenly-working artifact resolution, or discard the embedder change.

@mbien mbien added the ci:all-tests [ci] enable all tests label Jul 14, 2023
@mbien
Copy link
Member

mbien commented Jul 14, 2023

adding all-tests label since who knows what else uses the embedder/model indirectly

@apache apache locked and limited conversation to collaborators Jul 15, 2023
@apache apache unlocked this conversation Jul 15, 2023
@sdedic sdedic force-pushed the maven/missing-artifacts2 branch from 5462c82 to e2a14bf Compare July 15, 2023 21:04
Copy link
Contributor

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked again and still works 👍

The behavioral change of the #resolve method seems reasonable as both exceptions are checked exceptions so users are clearly warned. The code indicated, that the exception should have been thrown, so the fix brings the code into the intended line.

@mbien
Copy link
Member

mbien commented Jul 17, 2023

thanks everyone, merging in an hour or two so that it doesn't miss the deadline.

@mbien mbien merged commit af92e2c into apache:master Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:all-tests [ci] enable all tests Maven [ci] enable "build tools" tests Regression This used to work! VSCode Extension [ci] enable VSCode Extension tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"#5978: Maven/priming optimization" breaks loading broken project
4 participants