You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/11/22 09:26:36 UTC

[GitHub] [maven-enforcer] turbanoff opened a new pull request, #193: Avoid NullPointerException where there is no plugins

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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-enforcer] slawekjaranowski commented on pull request #193: Avoid NullPointerException where there is no plugins

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on PR #193:
URL: https://github.com/apache/maven-enforcer/pull/193#issuecomment-1366105743

   Thanks for fix
   I assume that we can also remove `catch ( NullPointerException e )` patterns 😄 
   
   Please resolve conflicts, and create an issue for tracking.
   


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-enforcer] slawekjaranowski merged pull request #193: [MENFORCER-459] Avoid NullPointerException where there is no plugins

Posted by GitBox <gi...@apache.org>.
slawekjaranowski merged PR #193:
URL: https://github.com/apache/maven-enforcer/pull/193


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-enforcer] turbanoff commented on pull request #193: Avoid NullPointerException where there is no plugins

Posted by GitBox <gi...@apache.org>.
turbanoff commented on PR #193:
URL: https://github.com/apache/maven-enforcer/pull/193#issuecomment-1376856094

   Created issue https://issues.apache.org/jira/browse/MENFORCER-459


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org