Skip to content

Commit

Permalink
Merge pull request wildfly-extras#215 from jfdenise/issue_213
Browse files Browse the repository at this point in the history
Fix for Issue wildfly-extras#213, NPE when feature pack <location> element content is not well formed
  • Loading branch information
jfdenise authored Mar 17, 2021
2 parents fb32b13 + 46e83e8 commit 808141c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,9 @@ private GalleonConfig buildGalleonConfig(ProvisioningManager pm) throws Provisio
if (fp.getLocation() != null) {
fp.setLocation(MavenUpgrade.locationWithVersion(fp.getLocation(), artifactVersions));
} else {
if (fp.getGroupId() == null || fp.getArtifactId() == null) {
throw new MojoExecutionException("Invalid Maven coordinates for galleon feature-pack ");
}
if (fp.getVersion() == null) {
Artifact fpArtifact = artifactVersions.getFeaturePackArtifact(fp.getGroupId(), fp.getArtifactId(), fp.getClassifier());
if (fpArtifact == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ static String locationWithVersion(String featurePackLocation, MavenProjectArtifa

private FeaturePack toFeaturePack(FeaturePackConfig cfg, ProvisioningManager pm) throws MojoExecutionException {
FeaturePack fp;
validateFPL(cfg.getLocation());
if (cfg.getLocation().isMavenCoordinates()) {
fp = getFeaturePack(cfg.getLocation().toString());
} else {
Expand All @@ -328,6 +329,12 @@ private FeaturePack toFeaturePack(FeaturePackConfig cfg, ProvisioningManager pm)
return fp;
}

private static void validateFPL(FeaturePackLocation fpl) throws MojoExecutionException {
if (fpl.getUniverse() == null || fpl.getProducer() == null) {
throw new MojoExecutionException("Invalid feature-pack location format: " + fpl);
}
}

String getMavenFeaturePack(FeaturePackLocation.FPID location) {
String gac = producerToGAC.get(location.getProducer());
if (gac == null) {
Expand Down

0 comments on commit 808141c

Please sign in to comment.