Skip to content

Commit

Permalink
JDF-496 - Fix NPE on SameVersionChecker
Browse files Browse the repository at this point in the history
  • Loading branch information
rafabene committed Sep 23, 2013
1 parent 4edfeb7 commit f5108bb
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ public Map<String, List<Violation>> check(MavenProject project, MavenSession mav
try {
Document doc = PositionalXMLReader.readXML(new FileInputStream(project.getFile()));
Node versionNode = (Node) getxPath().evaluate("/project/version", doc, XPathConstants.NODE);
rootVersion = versionNode.getTextContent();
if (versionNode == null) {
rootVersion = project.getVersion();
} else {
rootVersion = versionNode.getTextContent();
}
} catch (Exception e) {
throw new QSCheckerException(e);
}
Expand All @@ -80,7 +84,7 @@ public String getCheckerDescription() {
@Override
public void processProject(MavenProject project, Document doc, Map<String, List<Violation>> results) throws Exception {
Node versionNode = (Node) getxPath().evaluate("/project/version", doc, XPathConstants.NODE);
if (versionNode != null && !versionNode.getTextContent().equals(rootVersion)){
if (versionNode != null && !versionNode.getTextContent().equals(rootVersion)) {
int lineNumber = getLineNumberFromNode(versionNode);
String msg = "This project uses a version [%s] different from the root version [%s]";
addViolation(project.getFile(), results, lineNumber, String.format(msg, versionNode.getTextContent(), rootVersion));
Expand Down

0 comments on commit f5108bb

Please sign in to comment.