Uploaded image for project: 'Maven Enforcer Plugin'
  1. Maven Enforcer Plugin
  2. MENFORCER-459

Plugin shouldn't use NullPointerException for non-exceptional code flow

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.1.0
    • 3.2.0, 3.2.1
    • None
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              sjaranowski Slawomir Jaranowski
              turbanoff Andrey Turbanov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: