Skip to content

Commit

Permalink
NPE error and cleanup.
Browse files Browse the repository at this point in the history
Remove a null pointer error, fixes ##117
Cleanup some of the logging in the main trigger, fixes #118
  • Loading branch information
DavidTanner committed Jun 20, 2015
1 parent 9587b47 commit 17d6318
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import hudson.model.TaskListener;
import jenkins.model.Jenkins;

import org.apache.commons.codec.binary.Hex;
import org.jenkinsci.plugins.ghprb.extensions.GhprbCommentAppender;
import org.jenkinsci.plugins.ghprb.extensions.GhprbCommitStatusException;
import org.jenkinsci.plugins.ghprb.extensions.GhprbExtension;
Expand All @@ -15,9 +14,6 @@
import org.kohsuke.github.GHEventPayload.IssueComment;
import org.kohsuke.github.GHEventPayload.PullRequest;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/org/jenkinsci/plugins/ghprb/GhprbTrigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class GhprbTrigger extends GhprbTriggerBackwardsCompatible {
private List<GhprbBranch> whiteListTargetBranches;
private transient Ghprb helper;
private String project;
private AbstractProject<?, ?> _project;
private GhprbGitHubAuth gitHubApiAuth;


Expand Down Expand Up @@ -146,6 +147,7 @@ public static DescriptorImpl getDscp() {
public void start(AbstractProject<?, ?> project, boolean newInstance) {
// We should always start the trigger, and handle cases where we don't run in the run function.
super.start(project, newInstance);
this._project = project;
this.project = project.getFullName();

if (project.isDisabled()) {
Expand Down Expand Up @@ -190,15 +192,16 @@ public void run() {
return;
}

if (helper == null) {
logger.log(Level.SEVERE, "Helper is null, unable to run trigger");
if ((helper != null && helper.isProjectDisabled()) || (_project != null && _project.isDisabled())) {
logger.log(Level.FINE, "Project is disabled, ignoring trigger run call");

This comment has been minimized.

Copy link
@ixdy

ixdy Jun 20, 2015

Contributor

it might be helpful to include the project name in this error message, as is done on L206.
similarly for the next error message.

return;
}

if (helper.isProjectDisabled()) {
logger.log(Level.FINE, "Project is disabled, ignoring trigger run call");
if (helper == null) {
logger.log(Level.SEVERE, "Helper is null and Project is not disabled, unable to run trigger");
return;
}


logger.log(Level.FINE, "Running trigger for {0}", project);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ public void onBuildComplete(AbstractBuild<?, ?> build, TaskListener listener, GH
StringBuilder sb = new StringBuilder();

if (completedStatus == null || completedStatus.isEmpty()) {
sb.append("Build finished.");
} else {
for (GhprbBuildResultMessage buildStatus : completedStatus) {
sb.append(buildStatus.postBuildComment(build, listener));
}
} else {
sb.append("Build finished.");
}

sb.append(" ");
Expand Down

0 comments on commit 17d6318

Please sign in to comment.