Skip to content

Commit

Permalink
- added nullpointer checks
Browse files Browse the repository at this point in the history
- consolidation of usage @nonnull vs. @nonnull
  • Loading branch information
chcg committed Dec 2, 2024
1 parent 83eba49 commit 382f093
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory;
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
Expand Down Expand Up @@ -69,7 +70,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.jenkinsci.Symbol;
Expand Down Expand Up @@ -249,7 +249,7 @@ public JiraTestDataPublisher(
*/
@Override
public TestResultAction.Data contributeTestData(
Run<?, ?> run, @Nonnull FilePath workspace, Launcher launcher, TaskListener listener, TestResult testResult)
Run<?, ?> run, @NonNull FilePath workspace, Launcher launcher, TaskListener listener, TestResult testResult)
throws IOException, InterruptedException {

EnvVars envVars = run.getEnvironment(listener);
Expand Down Expand Up @@ -795,6 +795,10 @@ public FormValidation validateFieldConfigs(String jsonForm) throws FormException
}
}

if (jiraPublisherJSON == null) {
return FormValidation.error("jiraPublisherJSON is null.\n");

Check warning on line 799 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 798-799 are not covered by tests
}

// constructing the objects from json
List<AbstractFields> configs =
newInstancesFromHeteroList(req, jiraPublisherJSON.get("configs"), getListDescriptors());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ public synchronized void saveConfig(
* Method for setting the last configuration made for a project
*/
public synchronized void saveConfig(Job project, JobConfigEntry entry) {
if (project == null) {
return;

Check warning on line 398 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 397-398 are not covered by tests
}
if (entry instanceof JobConfigEntryBuilder) {
entry = ((JobConfigEntryBuilder) entry).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ private HashMap<String, String> loadMap(Job job) {
* @param job
*/
public void register(Job job) {
if (job == null) {
return;

Check warning on line 158 in src/main/java/org/jenkinsci/plugins/JiraTestResultReporter/TestToIssueMapping.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 157-158 are not covered by tests
}

if (job instanceof MatrixProject) {
for (Job child : ((MatrixProject) job).getAllJobs()) {
if (child instanceof MatrixProject) {
Expand Down

0 comments on commit 382f093

Please sign in to comment.