-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[MNG-6732] - DefaultArtifactDescriptorReader.loadPom to check IGNORE_MISSING policy upon ArtifactTransferException #277
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't ArtifactTransferException a temporary failure?
ArtifactNotFoundException sounds like the artifact is definitely not available.
Will this change add unpredictable behavior to builds?
@eolivelli Thank you for question.
ArtifactTransferException does not specify that. ArtifactTransferException can be a permanent failure from a retired repository (such as http://repository.codehaus.org/ ) as well as a temporary repository failure. ArtifactNotFoundException is subclass of ArtifactTransferException.
No, it does not add unpredictable behavior (as far as I know). Thinking of two cases:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it plausible to add a test for this?
...ider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
Outdated
Show resolved
Hide resolved
Sure, let me think how to test this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elharo Added test.
Okay. I feel I don't have enough context to sponsor this change, I am not saying I am -1 Any other committer with more insight on this kind of error? |
I need will some time to better understand this issue, so a review won't happen before end of this month. Maybe some other committer knows better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-o @elharo (Revisiting this) Would you review this PR?
...ider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice discovery
import org.eclipse.aether.resolution.ArtifactDescriptorRequest; | ||
import org.mockito.ArgumentCaptor; | ||
|
||
public class DefaultArtifactDescriptorReaderTest | ||
extends AbstractRepositoryTestCase | ||
{ | ||
|
||
public void testMng5459() | ||
DefaultArtifactDescriptorReader reader; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can be private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can be private
I agree, make this and the subsequent ones private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marked them as private.
@michael-o Did you get a chance to check this? |
I did a bit today, but am currently in a bad condition. Will try to pickup Thu or Fri. Still trying to wrap my head around the root problem. |
Sure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks fine at first glance and makes sense. Please modify the required spots. I will run unit tests and ITs.
import org.eclipse.aether.resolution.ArtifactDescriptorRequest; | ||
import org.mockito.ArgumentCaptor; | ||
|
||
public class DefaultArtifactDescriptorReaderTest | ||
extends AbstractRepositoryTestCase | ||
{ | ||
|
||
public void testMng5459() | ||
DefaultArtifactDescriptorReader reader; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can be private
I agree, make this and the subsequent ones private
.../src/test/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReaderTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-o Thank you for review. Updated them.
import org.eclipse.aether.resolution.ArtifactDescriptorRequest; | ||
import org.mockito.ArgumentCaptor; | ||
|
||
public class DefaultArtifactDescriptorReaderTest | ||
extends AbstractRepositoryTestCase | ||
{ | ||
|
||
public void testMng5459() | ||
DefaultArtifactDescriptorReader reader; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marked them as private.
.../src/test/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReaderTest.java
Outdated
Show resolved
Hide resolved
ITs are runing, I see repeated failures at home on my box and on a server at work. Will post the failures shortly. |
apache/maven-integration-testing@e284945 should fix the http issues (master is also back to blue). All branches need to merge in master |
These aren't the issues I see, still analyzing. |
OK, there is some work to be done. IT for MNG-5175 is failing. See http://home.apache.org/~michaelo/issues/MNG-6732/. It needs to be modified or split. @suztomo Do you have a proposal? @rfscholte What would be the proper approach here? The PR makes sense to me. |
Let me check tomorrow. (I thought I checked “mvn test -Prun-its”, but maybe I forgot) |
Don't forget, they are here: https://github.com/apache/maven-integration-testing |
https://issues.apache.org/jira/browse/MNG-5175 was fixed by @olamy so I hope he can provide feedback (but now he's enjoying holidays in Europe) |
@rfscholte The test itself is fine. I took at least two hours to understand why this is failing and it perfectly makes sense. The given IT simply tests for physical unavailability of a server, plus that an JAR POM artifact cannot be downloaded. We have changed the game in a way such that a missing POM can be ignored if the server is not available, it will continue with the JAR. So the breakage is correct. One simply need to adapt the test or copy to a new one. |
As mentioned by Jason, please don't touch old ITs. Better to copy it and adjust the mavenranges for both. |
That's probably the way even if it means code duplication. |
…SSING policy upon ArtifactTransferException This closes #277
I have uploaded a squash branch, will tests again.. |
Using https://github.com/apache/maven-integration-testing, I confirmed test failure > testmng5175_ReadTimeOutFromSettings
I'll follow that. |
I have pushed a branch for the ITs addressing this issue. |
Thank you, then I'll wait for the integration test updated. |
Here is the next problem: IT for MNG-3470 fails, see http://home.apache.org/~michaelo/issues/MNG-6732/IT-3470/. The checksum validation is ignored because the This is our problem in
|
I agree. The policy for the artifact should not have ArtifactDescriptorPolicy.IGNORE_MISSING. I see dependency setup is very normal. If the artifact is missing, the build should fail. |
The problem is that transfer is fine, the file is there, but checksum is intentionally wrong. So ignore missing does not apply here. It could be |
How about adding if statement for IGNORE_INVALID? (I'll do experiment next week) |
I did that: diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
index 0e9a5745e..da13f363d 100644
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
@@ -245,7 +245,7 @@ private Model loadPom( RepositorySystemSession session, ArtifactDescriptorReques
catch ( ArtifactResolutionException e )
{
Throwable cause = e.getCause();
- if ( cause instanceof ArtifactTransferException )
+ if ( cause instanceof ArtifactNotFoundException )
{
missingDescriptor( session, trace, a, (Exception) cause );
if ( ( getPolicy( session, a, request ) & ArtifactDescriptorPolicy.IGNORE_MISSING ) != 0 )
@@ -253,6 +253,14 @@ private Model loadPom( RepositorySystemSession session, ArtifactDescriptorReques
return null;
}
}
+ if ( cause instanceof ArtifactTransferException )
+ {
+ missingDescriptor( session, trace, a, (Exception) cause );
+ if ( ( getPolicy( session, a, request ) & ArtifactDescriptorPolicy.IGNORE_INVALID ) != 0 )
+ {
+ return null;
+ }
+ }
result.addException( e ); Doesn't make a difference. |
Memo for myself:
Maybe try |
@michael-o I cannot set breakpoints in IntelliJ to look at the values at line 250 of DefaultArtifactDescriptorReader.java for the test case; the test execution with the MAVEN_OPTS above does not stop there. Would you share how you setup debugger and your IDE/editor? |
Go to the interpolated IT directory in core-it-suite/target, use the args from the IT class and pass them to |
@michael-o Now I can debug it with IntelliJ. Thank you.
|
Memo for myself: Non-existent artifact (guava:30.0 below) causes mvn command failure but checksum verification failure doesn't. They both seem to go the same code path around this
|
@michael-o I think it's safer to special-case UnknownHostException. I confirmed that the integration tests pass. Would you take a look at this change? |
Will look at this tomorrow. |
…MISSING policy upon ArtifactTransferException
fbf6c42
to
acc53b7
Compare
This PR is to allow DefaultArtifactDescriptorReader.loadPom to check IGNORE_MISSING policy upon ArtifactTransferException.
Problem description in https://issues.apache.org/jira/browse/MNG-6732
Example project to demonstrate effect of ArtifactTransferException even when a dependency is unnecessary: https://github.com/suztomo/maven-missing-artifact .
Following this checklist to help us incorporate your
contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[MNG-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
MNG-XXX
with the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean verify
to make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.