[MENFORCER-459] Plugin shouldn't use NullPointerException for non-exceptional code flow (original) (raw)

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)

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.