Skip to content

Commit

Permalink
Added null checks to FileResourceModelSource
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Oct 24, 2013
1 parent fba71a4 commit 7b100a8
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.apache.maven.model.building.ModelSource2;
import org.jboss.forge.addon.resource.FileResource;
import org.junit.Assert;

/**
* Wraps a {@link FileResource} as a model source.
Expand All @@ -27,6 +28,7 @@ public class FileResourceModelSource implements ModelSource2

public FileResourceModelSource(FileResource<?> fileResource)
{
Assert.assertNotNull(fileResource);
this.fileResource = fileResource;
}

Expand All @@ -46,13 +48,13 @@ public ModelSource2 getRelatedSource(String relPath)
{
relPath = relPath.replace('\\', File.separatorChar).replace('/', File.separatorChar);
FileResource<?> relatedPom = fileResource.getParent().getChild(relPath).reify(FileResource.class);
if (relatedPom.isDirectory())
if (relatedPom != null && relatedPom.isDirectory())
{
// TODO figure out how to reuse ModelLocator.locatePom(File) here
relatedPom = relatedPom.getChild("pom.xml").reify(FileResource.class);
}

if (relatedPom.exists())
if (relatedPom != null && relatedPom.exists())
{
return new FileResourceModelSource(relatedPom);
}
Expand Down

0 comments on commit 7b100a8

Please sign in to comment.