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

Loading the build history causes an NPE on the History Widget

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: core
    • Labels:
      None
    • Similar Issues:

      Description

      When clicking more on a project with a long history, I get the following NPE in jenkins console:

      Winstone 2011/02/03 10:13:24] - Untrapped Error in Servlet
      javax.servlet.ServletException: java.lang.NullPointerException
      	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:597)
      	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:640)
      	at org.kohsuke.stapler.MetaClass$13.dispatch(MetaClass.java:382)
      	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:562)
      	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:640)
      	at org.kohsuke.stapler.MetaClass$7.doDispatch(MetaClass.java:242)
      	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
      	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:562)
      	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:640)
      	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:478)
      	at org.kohsuke.stapler.Stapler.service(Stapler.java:160)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:45)
      	at winstone.ServletConfiguration.execute(ServletConfiguration.java:249)
      	at winstone.RequestDispatcher.forward(RequestDispatcher.java:335)
      	at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:378)
      	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:94)
      	at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:86)
      	at winstone.FilterConfiguration.execute(FilterConfiguration.java:195)
      	at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:368)
      	at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:47)
      	at winstone.FilterConfiguration.execute(FilterConfiguration.java:195)
      	at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:368)
      	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
      	at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
      	at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
      	at winstone.FilterConfiguration.execute(FilterConfiguration.java:195)
      	at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:368)
      	at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
      	at winstone.FilterConfiguration.execute(FilterConfiguration.java:195)
      	at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:368)
      	at winstone.RequestDispatcher.forward(RequestDispatcher.java:333)
      	at winstone.RequestHandlerThread.processRequest(RequestHandlerThread.java:244)
      	at winstone.RequestHandlerThread.run(RequestHandlerThread.java:150)
      	at java.lang.Thread.run(Thread.java:662)
      Caused by: java.lang.NullPointerException
      	at java.lang.String.compareTo(String.java:1167)
      	at hudson.model.Job$2.compare(Job.java:447)
      	at hudson.model.Job$2.compare(Job.java:441)
      	at hudson.widgets.HistoryWidget.doAjax(HistoryWidget.java:163)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:282)
      	at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:149)
      	at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:88)
      	at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:102)
      	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
      	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:562)
      	... 33 more
      

      This is caused by the next scheduled call to buildHistory() which will lack the n parameter passed in the header as the loadAllBuildHistory() fails to properly keep track of the headers variable.

      I have a patch that fixes it but I would appreciate a review.

        Attachments

          Activity

          Show
          lacostej lacostej added a comment - Here's the patch. https://github.com/lacostej/jenkins/commit/3ddb68f038dabaa703583b6468bb3b22e3c808aa
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Kohsuke Kawaguchi
          Path:
          core/src/main/java/hudson/widgets/HistoryWidget.java
          core/src/main/resources/hudson/widgets/HistoryWidget/index.jelly
          war/src/main/webapp/scripts/hudson-behavior.js
          http://jenkins-ci.org/commit/core/691f23051989f85284a7c7739478e21af4ff5716
          Log:
          Merge branch 'JENKINS-8660'

          • JENKINS-8660:
            fail more gracefully if the header is not provided.
            JENKINS-8660: loading the build history cause an NPE on the History Widget
          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: core/src/main/java/hudson/widgets/HistoryWidget.java core/src/main/resources/hudson/widgets/HistoryWidget/index.jelly war/src/main/webapp/scripts/hudson-behavior.js http://jenkins-ci.org/commit/core/691f23051989f85284a7c7739478e21af4ff5716 Log: Merge branch ' JENKINS-8660 ' JENKINS-8660 : fail more gracefully if the header is not provided. JENKINS-8660 : loading the build history cause an NPE on the History Widget
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Kohsuke Kawaguchi
          Path:
          changelog.html
          core/src/main/java/hudson/widgets/HistoryWidget.java
          http://jenkins-ci.org/commit/core/6c521259e2b1061c105cb09724e4c29e8bc07ecd
          Log:
          [FIXED JENKINS-8660] recording the fix from Jerome Lacoste.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: changelog.html core/src/main/java/hudson/widgets/HistoryWidget.java http://jenkins-ci.org/commit/core/6c521259e2b1061c105cb09724e4c29e8bc07ecd Log: [FIXED JENKINS-8660] recording the fix from Jerome Lacoste.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Jerome Lacoste
          Path:
          core/src/main/java/hudson/widgets/HistoryWidget.java
          core/src/main/resources/hudson/widgets/HistoryWidget/index.jelly
          war/src/main/webapp/scripts/hudson-behavior.js
          http://jenkins-ci.org/commit/core/3ddb68f038dabaa703583b6468bb3b22e3c808aa
          Log:
          JENKINS-8660: loading the build history cause an NPE on the History Widget

          loadAllBuildHistory() fails to set the headers field on the replacement buildHistory DOM element.

          The patch fixes the problem by recreating a headers field.
          It also:

          • slightly refactor the loadAllBuildHistory() method for readability
          • add a FIXME note that the server side history widget should fail if the n parameter is missing.
          • add a pre-condition check to the buildHistory() update to catch potential bugs (note that the logging is disabled as Yahoo.log doesn't appear available)
          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jerome Lacoste Path: core/src/main/java/hudson/widgets/HistoryWidget.java core/src/main/resources/hudson/widgets/HistoryWidget/index.jelly war/src/main/webapp/scripts/hudson-behavior.js http://jenkins-ci.org/commit/core/3ddb68f038dabaa703583b6468bb3b22e3c808aa Log: JENKINS-8660 : loading the build history cause an NPE on the History Widget loadAllBuildHistory() fails to set the headers field on the replacement buildHistory DOM element. The patch fixes the problem by recreating a headers field. It also: slightly refactor the loadAllBuildHistory() method for readability add a FIXME note that the server side history widget should fail if the n parameter is missing. add a pre-condition check to the buildHistory() update to catch potential bugs (note that the logging is disabled as Yahoo.log doesn't appear available)
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Jerome Lacoste
          Path:
          core/src/main/java/hudson/widgets/HistoryWidget.java
          core/src/main/resources/hudson/widgets/HistoryWidget/index.jelly
          war/src/main/webapp/scripts/hudson-behavior.js
          http://jenkins-ci.org/commit/core/9a13990be96a4048d0c27537e473d4af4971a863
          Log:
          JENKINS-8660: loading the build history cause an NPE on the History Widget

          loadAllBuildHistory() fails to set the headers field on the replacement buildHistory DOM element.

          The patch fixes the problem by recreating a headers field.
          It also:

          • slightly refactor the loadAllBuildHistory() method for readability
          • add a FIXME note that the server side history widget should fail if the n parameter is missing.
          • add a pre-condition check to the buildHistory() update to catch potential bugs (note that the logging is disabled as Yahoo.log doesn't appear available)
          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jerome Lacoste Path: core/src/main/java/hudson/widgets/HistoryWidget.java core/src/main/resources/hudson/widgets/HistoryWidget/index.jelly war/src/main/webapp/scripts/hudson-behavior.js http://jenkins-ci.org/commit/core/9a13990be96a4048d0c27537e473d4af4971a863 Log: JENKINS-8660 : loading the build history cause an NPE on the History Widget loadAllBuildHistory() fails to set the headers field on the replacement buildHistory DOM element. The patch fixes the problem by recreating a headers field. It also: slightly refactor the loadAllBuildHistory() method for readability add a FIXME note that the server side history widget should fail if the n parameter is missing. add a pre-condition check to the buildHistory() update to catch potential bugs (note that the logging is disabled as Yahoo.log doesn't appear available)

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            lacostej lacostej
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: