Halil İbrahim Şener created SUREFIRE-2051:
---------------------------------------------
Summary: Propagate `ArtifactResolutionException` while resolving
artifacts in `SurefireDependencyResolver`
Key: SUREFIRE-2051
URL: https://issues.apache.org/jira/browse/SUREFIRE-2051
Project: Maven Surefire
Issue Type: Improvement
Affects Versions: 3.0.0-M5
Environment: Apache Maven 3.8.5
(3599d3414f046de2324203b78ddcf9b5e4388aa0)
maven-surefire-plugin 3.0.0-M5
Reporter: Halil İbrahim Şener
We see {{NullPointerException}}s from time to time, similar to
https://issues.apache.org/jira/browse/SUREFIRE-1837 and
https://issues.apache.org/jira/browse/SUREFIRE-1928. Relevant stack traces:
{code}
Caused by: java.lang.NullPointerException: Cannot invoke
"java.io.File.getAbsolutePath()" because the return value of
"org.apache.maven.artifact.Artifact.getFile()" is null
at
org.apache.maven.plugin.surefire.SurefireDependencyResolver.getProviderClasspath
(SurefireDependencyResolver.java:218)
at
org.apache.maven.plugin.surefire.SurefireDependencyResolver.getProviderClasspathAsMap
(SurefireDependencyResolver.java:230)
at
org.apache.maven.plugin.surefire.AbstractSurefireMojo$JUnitPlatformProviderInfo.getProviderClasspath
(AbstractSurefireMojo.java:3215)
at
org.apache.maven.plugin.surefire.AbstractSurefireMojo.newStartupConfigWithClasspath
(AbstractSurefireMojo.java:1908)
at
org.apache.maven.plugin.surefire.AbstractSurefireMojo.createStartupConfiguration
(AbstractSurefireMojo.java:1894)
{code}
and when debug is enabled:
{code}
Caused by: java.lang.NullPointerException: Cannot invoke
"java.io.File.getAbsolutePath()" because the return value of
"org.apache.maven.artifact.Artifact.getFile()" is null
at
org.apache.maven.plugin.surefire.AbstractSurefireMojo$ClasspathCache.setCachedClasspath
(AbstractSurefireMojo.java:4121)
at
org.apache.maven.plugin.surefire.AbstractSurefireMojo$ClasspathCache.access$200
(AbstractSurefireMojo.java:4102)
at
org.apache.maven.plugin.surefire.AbstractSurefireMojo.newStartupConfigWithClasspath
(AbstractSurefireMojo.java:1913)
at
org.apache.maven.plugin.surefire.AbstractSurefireMojo.createStartupConfiguration
(AbstractSurefireMojo.java:1894)
{code}
Mentioned tickets point to https://github.com/apache/maven/pull/627. However,
we had already upgraded to Maven 3.8.5 and it was still happening.
After digging the Surefire code, I realized NPE is a red herring because
Surefire doesn't propagate the issue during artifact resolution, and then
later, it fails with NPE. In our case, the remote repository wasn't reliable,
e.g., it sometimes returns 500.
I think Surefire should propagate the actual artifact resolution issue instead.
Similar to Maven compiler plugin
https://github.com/apache/maven-compiler-plugin/blob/785089d48541899b5c0a4677942b0f66c2f71d39/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java#L1838
--
This message was sent by Atlassian Jira
(v8.20.1#820001)