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

Comment Added event crashes with NullPointerException

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: gerrit-trigger-plugin
    • Labels:
      None
    • Environment:
      Debian 8

      root@jenkins:~# dpkg -l | grep -i jenkins
      ii jenkins 2.19.1 all continuous integration system

      Gerrit-trigger plugin 2.22.0
    • Similar Issues:

      Description

      When a "comment added" event is detected it crashes with a NullException, see below.

      I also saw the following warning message:
      WARNING: No GerritHandler was specified, won't register as event listener, so no function.

      It looks like the whole thing is caused when a Null GerritHandler gets passed here.
      https://github.com/jenkinsci/gerrit-trigger-plugin/blob/master/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/replication/ReplicationQueueTaskDispatcher.java#L107

      Here is logg when it crashes on a comment added event:

      INFO: Project [xxxx] triggered by Gerrit: [com.sonymobile.tools.gerrit.gerritevents.dto.events.CommentAdded@58561316]
      Oct 13, 2016 10:36:47 PM com.sonymobile.tools.gerrit.gerritevents.GerritHandler notifyListener
      SEVERE: Exception thrown during event handling.
      java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.sonymobile.tools.gerrit.gerritevents.GerritHandler.notifyListener(GerritHandler.java:316)
      at com.sonymobile.tools.gerrit.gerritevents.GerritHandler.notifyListeners(GerritHandler.java:296)
      at com.sonyericsson.hudson.plugins.gerrit.trigger.JenkinsAwareGerritHandler.notifyListeners(JenkinsAwareGerritHandler.java:77)
      at com.sonymobile.tools.gerrit.gerritevents.workers.AbstractGerritEventWork.perform(AbstractGerritEventWork.java:46)
      at com.sonymobile.tools.gerrit.gerritevents.workers.AbstractJsonObjectWork.perform(AbstractJsonObjectWork.java:77)
      at com.sonymobile.tools.gerrit.gerritevents.workers.StreamEventsStringWork.perform(StreamEventsStringWork.java:67)
      at com.sonymobile.tools.gerrit.gerritevents.workers.EventThread.run(EventThread.java:66)
      at com.sonyericsson.hudson.plugins.gerrit.trigger.SystemEventThread.run(SystemEventThread.java:66)
      Caused by: java.lang.NullPointerException
      at com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTriggerParameters.setOrCreateParameters(GerritTriggerParameters.java:447)
      at com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.EventListener.createParameters(EventListener.java:263)
      at com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.EventListener.schedule(EventListener.java:188)
      at com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.EventListener.schedule(EventListener.java:164)
      at com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.EventListener.gerritEvent(EventListener.java:152)
      ... 12 more

      Please let me know if you need anything else from my side.
      Best regards

        Attachments

          Activity

          Hide
          danc86 Dan C added a comment -

          Here is a PR including reproducer: https://github.com/jenkinsci/gerrit-trigger-plugin/pull/301

          Not sure if that's really the best place for the test though...

          Also, this has the downside of still requiring every job definition to be re-saved in order to avoid the NPE. I wonder if it might also be worthwhile to be defensive on the opposite side when handling the comment-added event, to use PLAIN if the option is set to null?

          Show
          danc86 Dan C added a comment - Here is a PR including reproducer: https://github.com/jenkinsci/gerrit-trigger-plugin/pull/301 Not sure if that's really the best place for the test though... Also, this has the downside of still requiring every job definition to be re-saved in order to avoid the NPE. I wonder if it might also be worthwhile to be defensive on the opposite side when handling the comment-added event, to use PLAIN if the option is set to null?
          Hide
          danc86 Dan C added a comment -

          Scratch that... doesn't require every job to be re-saved, I didn't realise that that readResolve() method magically fixes up any existing job definitions when the plugin is upgraded.

          Show
          danc86 Dan C added a comment - Scratch that... doesn't require every job to be re-saved, I didn't realise that that readResolve() method magically fixes up any existing job definitions when the plugin is upgraded.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Dan Callaghan
          Path:
          src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger.java
          src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/spec/BackCompat2173JenkinsTest.java
          http://jenkins-ci.org/commit/gerrit-trigger-plugin/814b85b771c9abdbca0273b6aa9bb8064762fef4
          Log:
          JENKINS-38974 fill in commentTextParameterMode if it's missing

          Any existing jobs which were configured before this option was added (or
          jobs uploaded as raw XML produced by Jenkins Job Builder, for example)
          will not have <commentTextParameterMode/>. Ensure it is filled in with
          the default value to avoid a NullPointerException later in the comment
          event handling.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Dan Callaghan Path: src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger.java src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/spec/BackCompat2173JenkinsTest.java http://jenkins-ci.org/commit/gerrit-trigger-plugin/814b85b771c9abdbca0273b6aa9bb8064762fef4 Log: JENKINS-38974 fill in commentTextParameterMode if it's missing Any existing jobs which were configured before this option was added (or jobs uploaded as raw XML produced by Jenkins Job Builder, for example) will not have <commentTextParameterMode/>. Ensure it is filled in with the default value to avoid a NullPointerException later in the comment event handling.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Robert Sandell
          Path:
          src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger.java
          src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/spec/BackCompat2173JenkinsTest.java
          http://jenkins-ci.org/commit/gerrit-trigger-plugin/579b5bdfa17430134d3fd50d3c72dbd0393a2336
          Log:
          Merge pull request #301 from beaker-project/JENKINS-38974-commentTextParameterMode-NPE

          JENKINS-38974 fill in commentTextParameterMode if it's missing

          Compare: https://github.com/jenkinsci/gerrit-trigger-plugin/compare/166b26cf6c3c...579b5bdfa174

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Robert Sandell Path: src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritTrigger.java src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/spec/BackCompat2173JenkinsTest.java http://jenkins-ci.org/commit/gerrit-trigger-plugin/579b5bdfa17430134d3fd50d3c72dbd0393a2336 Log: Merge pull request #301 from beaker-project/ JENKINS-38974 -commentTextParameterMode-NPE JENKINS-38974 fill in commentTextParameterMode if it's missing Compare: https://github.com/jenkinsci/gerrit-trigger-plugin/compare/166b26cf6c3c...579b5bdfa174
          Hide
          tobias_urdin Tobias Urdin added a comment -

          Hello Dan,
          Thanks for fixing this issue!

          Best regards

          Show
          tobias_urdin Tobias Urdin added a comment - Hello Dan, Thanks for fixing this issue! Best regards

            People

            • Assignee:
              rsandell rsandell
              Reporter:
              tobias_urdin Tobias Urdin
            • Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated: