Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-49170

NPE can be thrown on null triggers list

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: workflow-job-plugin
    • Labels:
    • Environment:
    • Similar Issues:

      Description

      Seen in some logs:

      2017-12-21 19:00:38.734+0000 [id=38]	WARNING	c.c.h.p.folder.AbstractFolder#loadChildren: could not load /tech/appl/default/jenkins/jobs/SDF_Dev/jobs/GroovyTest/jobs/Build_NewCode/jobs/Maven-POC
      java.lang.NullPointerException
      	at org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty.stopTriggers(PipelineTriggersJobProperty.java:96)
      	at org.jenkinsci.plugins.workflow.job.WorkflowJob.removeProperty(WorkflowJob.java:580)
      	at hudson.model.Job.removeProperty(Job.java:535)
      	at org.jenkinsci.plugins.workflow.job.WorkflowJob.setTriggers(WorkflowJob.java:540)
      	at org.jenkinsci.plugins.workflow.job.WorkflowJob.onLoad(WorkflowJob.java:152)
      	at com.cloudbees.hudson.plugins.folder.AbstractFolder.loadChildren(AbstractFolder.java:617)
      	at com.cloudbees.hudson.plugins.folder.AbstractFolder.onLoad(AbstractFolder.java:722)
      	at com.cloudbees.hudson.plugins.folder.Folder.onLoad(Folder.java:104)
      	at com.cloudbees.hudson.plugins.folder.AbstractFolder.loadChildren(AbstractFolder.java:617)
      	at com.cloudbees.hudson.plugins.folder.AbstractFolder.onLoad(AbstractFolder.java:722)
      	at com.cloudbees.hudson.plugins.folder.Folder.onLoad(Folder.java:104)
      	at com.cloudbees.hudson.plugins.folder.AbstractFolder.loadChildren(AbstractFolder.java:617)
      	at com.cloudbees.hudson.plugins.folder.AbstractFolder.onLoad(AbstractFolder.java:722)
      	at com.cloudbees.hudson.plugins.folder.Folder.onLoad(Folder.java:104)
      	at hudson.model.Items.load(Items.java:372)
      	at jenkins.model.Jenkins$17.run(Jenkins.java:3099)
      	at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
      	at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:282)
      	at jenkins.model.Jenkins$7.runTask(Jenkins.java:1073)
      	at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:210)
      	at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      

      It seems like the `triggers` attribute can be null in some circomstances, hence iterating on it triggers this NPE. Maybe some code called the setTriggers() method with a null parameter. So I think we should add some defensive checks like already done in the constructor to avoid this.

        Attachments

          Issue Links

            Activity

            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Baptiste Mathus
            Path:
            src/main/java/org/jenkinsci/plugins/workflow/job/properties/PipelineTriggersJobProperty.java
            http://jenkins-ci.org/commit/workflow-job-plugin/99061564244d8b96e3fc08ed4e564220bc08223f
            Log:
            JENKINS-49170 NPE can be thrown on null triggers list

            Protect about possible null value for the triggers attribute.

            This shouldn't be possible now with the current code, so I suppose
            from reading the code and doing some archeology that it was not
            100% protected before 3ad2875370d99b99686a2f0b6e88e97f7cfa4ec1 for
            instance where I see some defensive checks were added.

            Protecting against this seen in production:

            ```
            java.lang.NullPointerException
            at org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty.stopTriggers(PipelineTriggersJobProperty.java:96)
            at org.jenkinsci.plugins.workflow.job.WorkflowJob.removeProperty(WorkflowJob.java:580)
            at hudson.model.Job.removeProperty(Job.java:535)
            at org.jenkinsci.plugins.workflow.job.WorkflowJob.setTriggers(WorkflowJob.java:540)
            ```

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Baptiste Mathus Path: src/main/java/org/jenkinsci/plugins/workflow/job/properties/PipelineTriggersJobProperty.java http://jenkins-ci.org/commit/workflow-job-plugin/99061564244d8b96e3fc08ed4e564220bc08223f Log: JENKINS-49170 NPE can be thrown on null triggers list Protect about possible null value for the triggers attribute. This shouldn't be possible now with the current code, so I suppose from reading the code and doing some archeology that it was not 100% protected before 3ad2875370d99b99686a2f0b6e88e97f7cfa4ec1 for instance where I see some defensive checks were added. Protecting against this seen in production: ``` java.lang.NullPointerException at org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty.stopTriggers(PipelineTriggersJobProperty.java:96) at org.jenkinsci.plugins.workflow.job.WorkflowJob.removeProperty(WorkflowJob.java:580) at hudson.model.Job.removeProperty(Job.java:535) at org.jenkinsci.plugins.workflow.job.WorkflowJob.setTriggers(WorkflowJob.java:540) ```
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Sam Van Oort
            Path:
            src/main/java/org/jenkinsci/plugins/workflow/job/properties/PipelineTriggersJobProperty.java
            http://jenkins-ci.org/commit/workflow-job-plugin/023a0659bf9eb375b421ab2a777eb8bc5eaa8572
            Log:
            Merge pull request #86 from batmat/JENKINS-49170

            JENKINS-49170 NPE can be thrown on null triggers list

            Compare: https://github.com/jenkinsci/workflow-job-plugin/compare/5edc73925cce...023a0659bf9e

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Sam Van Oort Path: src/main/java/org/jenkinsci/plugins/workflow/job/properties/PipelineTriggersJobProperty.java http://jenkins-ci.org/commit/workflow-job-plugin/023a0659bf9eb375b421ab2a777eb8bc5eaa8572 Log: Merge pull request #86 from batmat/ JENKINS-49170 JENKINS-49170 NPE can be thrown on null triggers list Compare: https://github.com/jenkinsci/workflow-job-plugin/compare/5edc73925cce...023a0659bf9e
            Hide
            batmat Baptiste Mathus added a comment -

            PR merged, not yet released. Waiting for the next release.

            Show
            batmat Baptiste Mathus added a comment - PR merged, not yet released. Waiting for the next release.
            Hide
            svanoort Sam Van Oort added a comment -

            Released with v2.18

            Show
            svanoort Sam Van Oort added a comment - Released with v2.18

              People

              • Assignee:
                batmat Baptiste Mathus
                Reporter:
                batmat Baptiste Mathus
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: