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

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

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Minor Minor
    • workflow-job-plugin
    • None

      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);
      }

          [JENKINS-45067] PipelineTriggersJobProperty#startTriggers() throws NPE when the property is not assigned to job

          Oleg Nenashev created issue -
          Oleg Nenashev made changes -
          Description Original: 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}
          New: 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 made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Oleg Nenashev made changes -
          Assignee New: Oleg Nenashev [ oleg_nenashev ]
          Jesse Glick made changes -
          Link New: This issue duplicates JENKINS-42446 [ JENKINS-42446 ]
          Jesse Glick made changes -
          Remote Link New: This issue links to "PR 58 (Web Link)" [ 17213 ]
          Jesse Glick made changes -
          Link New: This issue relates to JENKINS-38454 [ JENKINS-38454 ]
          Jesse Glick made changes -
          Link New: This issue relates to JENKINS-34005 [ JENKINS-34005 ]
          Jesse Glick made changes -
          Resolution New: Not A Defect [ 7 ]
          Status Original: In Progress [ 3 ] New: Resolved [ 5 ]
          Oleg Nenashev made changes -
          Resolution Original: Not A Defect [ 7 ]
          Status Original: Resolved [ 5 ] New: Reopened [ 4 ]
          CloudBees Inc. made changes -
          Remote Link New: This issue links to "CloudBees Internal CJP-7447 (Web Link)" [ 18953 ]

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

              Created:
              Updated:
              Resolved: