Skip to content

Commit

Permalink
Merge pull request #168 from jglick/NPE
Browse files Browse the repository at this point in the history
NPE fix from `JiraTestDataPublisher.getJobName`
  • Loading branch information
imonteroperez authored Oct 23, 2024
2 parents 87b530e + 10a42af commit 7c59f48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ public List<String> getAttachments(String className, String name) {
* Getter for the project associated with this publisher
* @return
*/
private AbstractProject getJobName() {
return Stapler.getCurrentRequest().findAncestorObject(AbstractProject.class);
private @CheckForNull AbstractProject getJobName() {
StaplerRequest currentRequest = Stapler.getCurrentRequest();
return currentRequest != null ? currentRequest.findAncestorObject(AbstractProject.class) : null;

Check warning on line 157 in src/main/java/org/jenkinsci/plugins/JiraTestResultReporter/JiraTestDataPublisher.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 156-157 are not covered by tests
}

private boolean pipelineInvocation = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.model.Job;
import java.io.FileInputStream;
Expand Down Expand Up @@ -400,7 +401,10 @@ public synchronized void saveConfig(Job project, JobConfigEntry entry) {
save(project, entry);
}

private JobConfigEntry getJobConfigEntry(Job project) {
private JobConfigEntry getJobConfigEntry(@CheckForNull Job project) {
if (project == null) {
return null;

Check warning on line 406 in src/main/java/org/jenkinsci/plugins/JiraTestResultReporter/JobConfigMapping.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 405-406 are not covered by tests
}
if (!configMap.containsKey(project.getFullName())) {
JobConfigEntry entry = load(project);
if (entry != null) {
Expand Down

0 comments on commit 7c59f48

Please sign in to comment.