Skip to content

Commit

Permalink
[FIXED JENKINS-12849] NullPointerException when parsing changeset of …
Browse files Browse the repository at this point in the history
…Matrix Project.
  • Loading branch information
ssogabe committed Feb 28, 2012
1 parent 04bde09 commit 67860a2
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/main/java/hudson/plugins/mantis/Updater.java
@@ -1,11 +1,13 @@
package hudson.plugins.mantis;

import hudson.matrix.MatrixRun;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.Hudson;
import hudson.model.Result;
import hudson.model.Run;
import hudson.model.AbstractBuild.DependencyChange;
import hudson.model.Job;
import hudson.plugins.mantis.changeset.ChangeSet;
import hudson.plugins.mantis.changeset.ChangeSetFactory;
import hudson.plugins.mantis.model.MantisIssue;
Expand Down Expand Up @@ -81,8 +83,7 @@ boolean perform(final AbstractBuild<?, ?> build, final BuildListener listener) {
}
}

final MantisProjectProperty mpp =
build.getParent().getProperty(MantisProjectProperty.class);
MantisProjectProperty mpp = getMantisProjectProperty(build);
build.getActions().add(
new MantisBuildAction(mpp.getRegexpPattern(), issues.toArray(new MantisIssue[0])));

Expand Down Expand Up @@ -131,8 +132,8 @@ private List<ChangeSet> findChangeSets(final AbstractBuild<?, ?> build) {

private List<ChangeSet> findChangeSetsFromSCM(final AbstractBuild<?, ?> build) {
final List<ChangeSet> changeSets = new ArrayList<ChangeSet>();
final MantisProjectProperty mpp = build.getParent().getProperty(MantisProjectProperty.class);


MantisProjectProperty mpp = getMantisProjectProperty(build);
final Pattern pattern = mpp.getRegexpPattern();
for (final Entry change : build.getChangeSet()) {
final Matcher matcher = pattern.matcher(change.getMsg());
Expand All @@ -148,8 +149,19 @@ private List<ChangeSet> findChangeSetsFromSCM(final AbstractBuild<?, ?> build) {
changeSets.add(ChangeSetFactory.newInstance(id, build, change));
}
}

return changeSets;
}

private MantisProjectProperty getMantisProjectProperty(AbstractBuild<?, ?> build) {
Job<?, ?> job;
if (build instanceof MatrixRun) {
job = ((MatrixRun) build).getProject().getParent();
} else {
job = build.getProject();
}
return job.getProperty(MantisProjectProperty.class);
}

private static final Logger LOGGER = Logger.getLogger(Updater.class.getName());
}

0 comments on commit 67860a2

Please sign in to comment.