Skip to content

Commit

Permalink
[FIXED JENKINS-13215] NullPointerException when Category have value :…
Browse files Browse the repository at this point in the history
… not selected.
  • Loading branch information
ssogabe committed Apr 1, 2012
1 parent 186afee commit b8b2540
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/java/hudson/plugins/mantis/MantisIssueRegister.java
Expand Up @@ -68,10 +68,14 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
}

int no;
MantisIssue issue = createIssue(build);
MantisIssue issue = createIssue(build, listener);
if (issue == null) {
Utility.log(logger, "skipping file a ticket ...");
return true;
}
try {
no = site.addIssue(issue);
Utility.log(logger, "file ticket #" + no + "(" + getIssueURL(site, no) + ")");
Utility.log(logger, "file a ticket #" + no + "(" + getIssueURL(site, no) + ")");
} catch (MantisHandlingException e) {
Utility.log(logger, e.toString());
build.setResult(Result.FAILURE);
Expand All @@ -97,11 +101,13 @@ private String getIssueURL(MantisSite site, int no) {
return site.getIssueLink(no);
}

private MantisIssue createIssue(AbstractBuild<?, ?> build) throws IOException, InterruptedException {
private MantisIssue createIssue(AbstractBuild<?, ?> build, BuildListener listener)
throws IOException, InterruptedException {
MantisProjectProperty mpp = getMantisProjectProperty(build);
int projectId = mpp.getProjectId();
String categoryName = mpp.getCategory();
if (projectId == MantisProject.NONE || MantisCategory.None.equals(categoryName)) {
Utility.log(listener.getLogger(), "Neither project nor category selected.");
return null;
}

Expand Down
Expand Up @@ -131,6 +131,9 @@ public List<MantisCategory> getCategories(int projectId) throws MantisHandlingEx
}

public int addIssue(MantisIssue issue) throws MantisHandlingException {
if (issue == null) {
throw new MantisHandlingException("issue should not be null.");
}
IssueData data = new IssueData();
MantisProject project = issue.getProject();
if (project == null) {
Expand Down
Expand Up @@ -130,6 +130,9 @@ public List<MantisCategory> getCategories(int projectId) throws MantisHandlingEx
}

public int addIssue(MantisIssue issue) throws MantisHandlingException {
if (issue == null) {
throw new MantisHandlingException("issue should not be null.");
}
IssueData data = new IssueData();
MantisProject project = issue.getProject();
if (project == null) {
Expand Down

0 comments on commit b8b2540

Please sign in to comment.