turbanoff opened a new pull request, #193:
URL: https://github.com/apache/maven-enforcer/pull/193
When I debugged build of my project I noticed that maven-enforcer-plugin
generates lots of NPEs with this stack trace:
at java.util.ArrayList.addAll(ArrayList.java:702)
at
org.apache.maven.plugins.enforcer.RequirePluginVersions.getReportingPlugins(RequirePluginVersions.java:1062)
at
org.apache.maven.plugins.enforcer.RequirePluginVersions.getAllPluginEntries(RequirePluginVersions.java:970)
at
org.apache.maven.plugins.enforcer.RequirePluginVersions.execute(RequirePluginVersions.java:237)
at
org.apache.maven.plugins.enforcer.EnforceMojo.execute(EnforceMojo.java:199)
- locked <0x1eb6> (a
org.apache.maven.plugins.enforcer.RequirePluginVersions)
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at
org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:301)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:211)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:165)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:157)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:121)
at
org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:210)
at
org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:195)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:829)
Exceptions shouldn't be used for non-exceptional flow.
Also it's considered bad practice to return `null` from a method which
returns collection. Empty collection should be returned instead.
I checked all current usages of this method. All of them use this pattern:
```
try
{
//...
plugins.addAll( PluginWrapper.addAll( /*..*/ );
}
catch ( NullPointerException e )
{
// guess there are no plugins here.
}
```
So, it's safe to change return value to `emptyList()` - nothing will be
added to `plugins` in either case.
- [x] I have run the integration tests successfully (`mvn -Prun-its clean
verify`).
- [x] I hereby declare this contribution to be licenced under the [Apache
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]