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

NodeJS Plugin gets NullPointerException for Cache Location after update

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: nodejs-plugin
    • Labels:
      None
    • Environment:
      nodejs-plugin 1.3.0
    • Similar Issues:
    • Released As:
      1.3.1

      Description

      After update of nodejs-plugin from 1.2.9 to 1.3.0 the jobs, which use it, started to fail with the following stacktrace:

       

      java.lang.NullPointerException
        at jenkins.plugins.nodejs.NodeJSBuildWrapper.setUp(NodeJSBuildWrapper.java:166)
        at jenkins.tasks.SimpleBuildWrapper.setUp(SimpleBuildWrapper.java:146)
        at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:667)
        at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
        at hudson.model.Run.execute(Run.java:1818)
        at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
        at hudson.model.ResourceController.execute(ResourceController.java:97)
        at hudson.model.Executor.run(Executor.java:429)

      After some research and debugging I figured out the root of this issue. The plugin introduced cache locator strategy in commit 32039bd. It also guarantees that cache locator strategy cannot be null both after calling the constructor and calling the appropriate setter method. But that applies only if we create a new job or change the configuration for nodejs for an existing job, using nodejs-plugin 1.3.0. The config.xml of the job looks like that then:

       

      <jenkins.plugins.nodejs.NodeJSBuildWrapper plugin="nodejs@1.3.0">
        <nodeJSInstallationName>NodeJS_9_latest</nodeJSInstallationName>
        <cacheLocationStrategy class="jenkins.plugins.nodejs.cache.DefaultCacheLocationLocator"/>
      </jenkins.plugins.nodejs.NodeJSBuildWrapper>

      But if you have an existing job, which was created before nodejs-plugin 1.3.0, it is missing the configuration for cache locator strategy. Here is an example config.xml:

       

      <jenkins.plugins.nodejs.NodeJSBuildWrapper plugin="nodejs@1.2.9">
        <nodeJSInstallationName>NodeJS_9_latest</nodeJSInstallationName>
      </jenkins.plugins.nodejs.NodeJSBuildWrapper>

      And apparently the instance of NodeJSBuildWrapper isn't built via constructor but via straight object deserialization and the field is missing.

      Anway the fact is: all my nodejs jobs became broken after that update. Would it be possible to have a global fix for that?

       

       

        Attachments

          Issue Links

            Activity

            Hide
            smasher Daniel Estermann added a comment - - edited

            What I've learned from the documentation is that you need `readResolve()` method, when introducing a new field to retain backward compatibility.

            Show
            smasher Daniel Estermann added a comment - - edited What I've learned from the documentation  is that you need `readResolve()` method, when introducing a new field to retain backward compatibility.
            Show
            smasher Daniel Estermann added a comment - Created PR https://github.com/jenkinsci/nodejs-plugin/pull/26
            Hide
            nfalco Nikolas Falco added a comment -

            Thanks very much for all documentation reported and the PR.
            I have add some test case to you PR

            Show
            nfalco Nikolas Falco added a comment - Thanks very much for all documentation reported and the PR. I have add some test case to you PR

              People

              Assignee:
              nfalco Nikolas Falco
              Reporter:
              smasher Daniel Estermann
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: