Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2da7a68

Browse files
cpfeifferslawekjaranowski
authored andcommitted
Add null checks for modelId in PluginWrapper
In certain special scenarios (virtual maven-tiles), modelId can be null.
1 parent 91eb4d9 commit 2da7a68

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/utils/PluginWrapper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ public static Optional<Boolean> isVersionFromDefaultLifecycleBindings(InputLocat
8181
}
8282

8383
String modelId = versionLocation.getSource().getModelId();
84+
if (modelId == null) {
85+
return Optional.empty();
86+
}
8487
return Optional.of(
8588
modelId.startsWith("org.apache.maven:maven-core:") && modelId.endsWith(":default-lifecycle-bindings"));
8689
}
@@ -100,6 +103,9 @@ public static Optional<Boolean> isVersionFromSuperpom(InputLocationTracker o) {
100103
}
101104

102105
String modelId = versionLocation.getSource().getModelId();
106+
if (modelId == null) {
107+
return Optional.empty();
108+
}
103109
return Optional.of(
104110
modelId.startsWith("org.apache.maven:maven-model-builder:") && modelId.endsWith(":super-pom"));
105111
}

0 commit comments

Comments
 (0)