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

PipelineTriggersJobProperty#startTriggers() throws NPE when the property is not assigned to job

    Details

    • Similar Issues:

      Description

      When somebody creates a property in API and occasionally triggers the startTriggers() method, Trigger#start(owner, bool) gets invoked with null argument, which violates the contract and causes NPE.

      java.lang.NullPointerException
       at hudson.triggers.Trigger.start(Trigger.java:94)
       at org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty.startTriggers(PipelineTriggersJobProperty.java:103)
       at .... (whatever code)

      I think this NPE should be prevented, because such behavior is not documented in the class Javadoc, and hence API users may expect a robust behavior.

       

      I have hit it in one of the proprietary Job templating engines, but actually it is a valid case reproducible via a simple test (see below). 

      public void triggerMethodsShouldNotThrowNPEWhenNotAssigned() {
        MockTrigger t = new MockTrigger();
        PipelineTriggersJobProperty prop = new PipelineTriggersJobProperty(Arrays.asList(t));
      
        prop.startTriggers(true);
      }

        Attachments

          Issue Links

            Activity

            oleg_nenashev Oleg Nenashev created issue -
            oleg_nenashev Oleg Nenashev made changes -
            Field Original Value New Value
            Description When somebody creates a property in API and occasionally triggers the startTriggers() method, Trigger#start(owner, bool) gets invoked with null argument, which violates the contract and causes NPE.
            java.lang.NullPointerException
            at hudson.triggers.Trigger.start(Trigger.java:94)
            at org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty.startTriggers(PipelineTriggersJobProperty.java:103)
                    at .... (whatever code)
            I think this NPE should be prevented, because such behavior is not documented in the class Javadoc, and hence API users may expect a robust behavior.

             

            I have hit it in one of the proprietary Job templating engines, but actually it is a valid case reproducible via a simple test (see below). 
            {code:java}
            public void triggerMethodsShouldNotThrowNPEWhenNotAssigned() {
              MockTrigger t = new MockTrigger();
              PipelineTriggersJobProperty prop = new PipelineTriggersJobProperty(Arrays.asList(t));

              prop.startTriggers(true);
            }{code}
            When somebody creates a property in API and occasionally triggers the startTriggers() method, Trigger#start(owner, bool) gets invoked with null argument, which violates the contract and causes NPE.
            {code:java}
            java.lang.NullPointerException
             at hudson.triggers.Trigger.start(Trigger.java:94)
             at org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty.startTriggers(PipelineTriggersJobProperty.java:103)
             at .... (whatever code){code}

             I think this NPE should be prevented, because such behavior is not documented in the class Javadoc, and hence API users may expect a robust behavior.

             

            I have hit it in one of the proprietary Job templating engines, but actually it is a valid case reproducible via a simple test (see below). 
            {code:java}
            public void triggerMethodsShouldNotThrowNPEWhenNotAssigned() {
              MockTrigger t = new MockTrigger();
              PipelineTriggersJobProperty prop = new PipelineTriggersJobProperty(Arrays.asList(t));

              prop.startTriggers(true);
            }{code}
            oleg_nenashev Oleg Nenashev made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            oleg_nenashev Oleg Nenashev made changes -
            Assignee Oleg Nenashev [ oleg_nenashev ]
            jglick Jesse Glick made changes -
            Link This issue duplicates JENKINS-42446 [ JENKINS-42446 ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "PR 58 (Web Link)" [ 17213 ]
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-38454 [ JENKINS-38454 ]
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-34005 [ JENKINS-34005 ]
            jglick Jesse Glick made changes -
            Status In Progress [ 3 ] Resolved [ 5 ]
            Resolution Not A Defect [ 7 ]
            oleg_nenashev Oleg Nenashev made changes -
            Resolution Not A Defect [ 7 ]
            Status Resolved [ 5 ] Reopened [ 4 ]
            cloudbees CloudBees Inc. made changes -
            Remote Link This issue links to "CloudBees Internal CJP-7447 (Web Link)" [ 18953 ]

              People

              • Assignee:
                oleg_nenashev Oleg Nenashev
                Reporter:
                oleg_nenashev Oleg Nenashev
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: