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

NullPointerException during SCM polling

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Major
    • Resolution: Fixed
    • core
    • None
    • Jenkins version 2.11

    Description

      After updating from 2.10 to 2.11, I see the following stacktrace for a job that has SCM polling enabled:

      Jun 27, 2016 2:56:39 PM hudson.triggers.SCMTrigger$Runner runPolling
      SEVERE: Failed to record SCM polling for hudson.maven.MavenModuleSet@6ff62dfd[WFIAM Build]
      java.lang.NullPointerException
      at jenkins.triggers.SCMTriggerItem$SCMTriggerItems$Bridge.poll(SCMTriggerItem.java:124)
      at hudson.triggers.SCMTrigger$Runner.runPolling(SCMTrigger.java:528)
      at hudson.triggers.SCMTrigger$Runner.run(SCMTrigger.java:574)
      at hudson.util.SequentialExecutionQueue$QueueEntry.run(SequentialExecutionQueue.java:119)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      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)

      In this case, polling is triggered by hitting the /notifyCommit endpoint from a GitLab webhook.

      Attachments

        Issue Links

          Activity

            marmaluke Mark Lemmon added a comment -

            I've had a look through the source code already.

            SCMDecisionHandler veto = SCMDecisionHandler.firstShouldPollVeto(asItem());
            if (!veto.shouldPoll(asItem())) { ...

            Looks like the NPE is from using a nullable variable without first checking that it's non-null.

            In fact, looking at the implementation of SCMDecisionHandler.firstShouldPollVeto, it definitely returns null when there are no handlers that veto the poll.

            Not checking for null in this case is ... not great.

            marmaluke Mark Lemmon added a comment - I've had a look through the source code already. SCMDecisionHandler veto = SCMDecisionHandler.firstShouldPollVeto(asItem()); if (!veto.shouldPoll(asItem())) { ... Looks like the NPE is from using a nullable variable without first checking that it's non-null. In fact, looking at the implementation of SCMDecisionHandler.firstShouldPollVeto, it definitely returns null when there are no handlers that veto the poll. Not checking for null in this case is ... not great.

            What is the variable that should be set though?

            I am getting this for Matrix Project's GitHub webhooks as well as local SCM polling:

            ERROR: Failed to record SCM polling for hudson.matrix.MatrixProject...

            panajev Goffredo Marocchi added a comment - What is the variable that should be set though? I am getting this for Matrix Project's GitHub webhooks as well as local SCM polling: ERROR: Failed to record SCM polling for hudson.matrix.MatrixProject...
            thomasgp ThomasGP added a comment -

            This NPE breaks my git post-recieve-hook, too. The stacktrace also shows in the Git Polling Log of the job. The NPE seems to origin from the only issue resolved from Jenkins 2.10 to 2.11.

            Proposal for a fix:

            Change line 124 of SCMTriggerItem, add a null check:

            if (veto != null && !veto.shouldPoll(asItem())) {
            

            if "veto" is indeed null, no one vetoed the polling, so the method call should lead to the delegate.poll(listener) line below, as it is the case currently.

            thomasgp ThomasGP added a comment - This NPE breaks my git post-recieve-hook, too. The stacktrace also shows in the Git Polling Log of the job. The NPE seems to origin from the only issue resolved from Jenkins 2.10 to 2.11. Proposal for a fix: Change line 124 of SCMTriggerItem, add a null check: if (veto != null && !veto.shouldPoll(asItem())) { if "veto" is indeed null, no one vetoed the polling, so the method call should lead to the delegate.poll(listener) line below, as it is the case currently.
            thomasgp ThomasGP added a comment -

            Implemented the mini-fix in a pull request over at github.

            thomasgp ThomasGP added a comment - Implemented the mini-fix in a pull request over at github.

            I have this same problem!

            palerique Paulo Henrique Lerbach Rodrigues added a comment - I have this same problem!
            yunner Youfei Chen added a comment -

            I ran into this issue for only one of my jobs. Had to revert to 2.0.8 to make it working again.

            yunner Youfei Chen added a comment - I ran into this issue for only one of my jobs. Had to revert to 2.0.8 to make it working again.
            danielbeck Daniel Beck added a comment -

            Fixed by https://github.com/jenkinsci/jenkins/pull/2425 towards Jenkins 2.12.

            danielbeck Daniel Beck added a comment - Fixed by https://github.com/jenkinsci/jenkins/pull/2425 towards Jenkins 2.12.

            People

              Unassigned Unassigned
              marmaluke Mark Lemmon
              Votes:
              17 Vote for this issue
              Watchers:
              18 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: