Skip to content

Commit

Permalink
Guard against NPE in MavenVisitor#visitPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider committed Feb 28, 2024
1 parent e7622c8 commit e2a8cb8
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,15 @@ public boolean isDependencyLikeTag() {
@Nullable
public Plugin findPlugin(Xml.Tag tag) {
List<Plugin> plugins = getResolutionResult().getPom().getPlugins();
for (Plugin resolvedPlugin : plugins) {
String reqGroup = resolvedPlugin.getGroupId();
String reqVersion = resolvedPlugin.getVersion();
if ((reqGroup == null || reqGroup.equals(tag.getChildValue("groupId").orElse(null))) &&
resolvedPlugin.getArtifactId().equals(tag.getChildValue("artifactId").orElse(null)) &&
(reqVersion == null || reqVersion.equals(tag.getChildValue("version").orElse(null)))) {
return resolvedPlugin;
if(plugins != null) {
for (Plugin resolvedPlugin : plugins) {
String reqGroup = resolvedPlugin.getGroupId();
String reqVersion = resolvedPlugin.getVersion();
if ((reqGroup == null || reqGroup.equals(tag.getChildValue("groupId").orElse(null))) &&
resolvedPlugin.getArtifactId().equals(tag.getChildValue("artifactId").orElse(null)) &&
(reqVersion == null || reqVersion.equals(tag.getChildValue("version").orElse(null)))) {
return resolvedPlugin;
}
}
}
return null;
Expand Down

0 comments on commit e2a8cb8

Please sign in to comment.