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

Jenkinsfile build fail - Null pointer exception in PipelineTriggersJobProperty

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • workflow-job-plugin
    • None

      I have Jenkinsfile build and workflow-job plugin installed. Jenkins and all plugins on latest version. When my build first fail (i think reason is not important, some error in Jenkinsfile script) every next build fail on NPE.

      I think failed build broke some trigger - set it to null, i don't know why, but it is real. Because every next build try to stop all triggers, every next build fail on NPE. So this job is broken forever.

      I think broken code is on PipelineTriggersJobProperty.java:106. Fix is easy - add 

      if (trigger !=null) {

      condition.

      And .. voilĂ  - problem is gone. 

          [JENKINS-63577] Jenkinsfile build fail - Null pointer exception in PipelineTriggersJobProperty

          Petr Leitner added a comment -

          New version 2.40 of plugin was today installed on my jenkins and my patched plugin is gone and problem is back. It means last version 2.40 still has this problem. Please fix.

          Petr Leitner added a comment - New version 2.40 of plugin was today installed on my jenkins and my patched plugin is gone and problem is back. It means last version 2.40 still has this problem. Please fix.

          Petr Leitner added a comment -

          Problem si much wider, bug is on many places in PipelineTriggersJobProperty.java.

          As you can see here, author assume one trigger may come null from outside:

           

          public void removeTrigger(Trigger t) {
           // TODO: Will we get equality for trigger instances of the same Descriptor?
           Trigger toRemove = getTriggerForDescriptor(t.getDescriptor());
          
           if (toRemove != null) {
           triggers.remove(toRemove);
           }
          }
          

           

          But other places in this source are not null-safe, for example:

           

          public void stopTriggers() {
           for (Trigger trigger : triggers) {
           trigger.stop();
           }
          }
          

           

          A have fixed source, but i cannot make pull requests. Why?

          Petr Leitner added a comment - Problem si much wider, bug is on many places in PipelineTriggersJobProperty.java. As you can see here, author assume one trigger may come null from outside:   public void removeTrigger(Trigger t) { // TODO: Will we get equality for trigger instances of the same Descriptor? Trigger toRemove = getTriggerForDescriptor(t.getDescriptor()); if (toRemove != null ) { triggers.remove(toRemove); } }   But other places in this source are not null-safe, for example:   public void stopTriggers() { for (Trigger trigger : triggers) { trigger.stop(); } }   A have fixed source, but i cannot make pull requests. Why?

          Jesse Glick added a comment -

          A patch making the exception go away is trivially recreated, but what we need is steps to reproduce the problem from scratch. Quite possibly the real bug lies in another component, but to analyze that it is necessary to get more information.

          Jesse Glick added a comment - A patch making the exception go away is trivially recreated, but what we need is steps to reproduce the problem from scratch . Quite possibly the real bug lies in another component, but to analyze that it is necessary to get more information.

          Petr Leitner added a comment -

          I understand your argument. But i cannot reproduce problem because i have no idea which part of jenkins insert null into triggers. And i think i will never know how it is possible. So i think this plugin should be fixed as resistant against null values in triggers List. Maybe some logger.warn should be added to detect future "null cases".

           

          And as I mentioned above - source is inconsistent - on one place it handles null in trigger on input, but on other places not.

          Petr Leitner added a comment - I understand your argument. But i cannot reproduce problem because i have no idea which part of jenkins insert null into triggers. And i think i will never know how it is possible. So i think this plugin should be fixed as resistant against null values in triggers List. Maybe some logger.warn should be added to detect future "null cases".   And as I mentioned above - source is inconsistent - on one place it handles null in trigger on input, but on other places not.

          Jesse Glick added a comment -

          i have no idea which part of jenkins insert null into trigger

          Presumably some buggy plugin. You could bisect based on plugin installation list, though there may be a way to insert a diagnostic stack trace elsewhere, in Jenkins core perhaps.

          Vaguely recall some related issue a few years ago.

          Jesse Glick added a comment - i have no idea which part of jenkins insert null into trigger Presumably some buggy plugin. You could bisect based on plugin installation list, though there may be a way to insert a diagnostic stack trace elsewhere, in Jenkins core perhaps. Vaguely recall some related issue a few years ago.

          Petr Leitner added a comment -

          Try to understand. I have production jenkins server and I found "not stable", "not robust", "weird" code in workflow-job-plugin. It is absolutely not possible i will investigate more. I did what I did and I will not do anything more, because it's almost impossible to find which part of Jenkins created "null" trigger. And it is totally impossible i will do some tests on my Jenkins instance. 

           

          Still i think someone should fix this plugin to be rock stable = null trigger resistant. And if you insert some extra logging maybe me or someone other will catch that log message and maybe it will point to other buggy part of Jenkins.

          Petr Leitner added a comment - Try to understand. I have production jenkins server and I found "not stable", "not robust", "weird" code in workflow-job-plugin. It is absolutely not possible i will investigate more. I did what I did and I will not do anything more, because it's almost impossible to find which part of Jenkins created "null" trigger. And it is totally impossible i will do some tests on my Jenkins instance.    Still i think someone should fix this plugin to be rock stable = null trigger resistant. And if you insert some extra logging maybe me or someone other will catch that log message and maybe it will point to other buggy part of Jenkins.

          Petr Leitner added a comment - - edited

          Any progress here? Blocker bug is still there and blocks our builds. I have verified source fix but nobody wants it? No way how to open PR?

          Petr Leitner added a comment - - edited Any progress here? Blocker bug is still there and blocks our builds. I have verified source fix but nobody wants it? No way how to open PR?

          Petr Leitner added a comment -

          Still no progress? Plugin still buggy i still have to use own patched version..

          Petr Leitner added a comment - Still no progress? Plugin still buggy i still have to use own patched version..

          Petr Leitner added a comment -

          Any update here?

          Petr Leitner added a comment - Any update here?

            Unassigned Unassigned
            bigboban Petr Leitner
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: