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

Tasks plugin doesnt work over master-slave

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: tasks-plugin
    • Labels:
      None
    • Environment:
      Platform: All, OS: All
    • Similar Issues:

      Description

      When you setup a slave to do a build the tasks plugin fails to run with a NPE
      (ignore the line numbers, they are off since the plugin has been modified a
      number of times in CVS since the last release, I'll give the correct line
      numbers later):

      BUILD SUCCESSFUL
      Total time: 7 minutes 13 seconds
      Scanning workspace files for tasks...
      FATAL: null
      java.lang.NullPointerException
      at hudson.plugins.tasks.WorkspaceScanner.invoke(WorkspaceScanner.java:63)
      at hudson.plugins.tasks.WorkspaceScanner.invoke(WorkspaceScanner.java:23)
      at hudson.FilePath$FileCallableWrapper.call(FilePath.java:1084)
      at hudson.remoting.UserRequest.perform(UserRequest.java:69)
      at hudson.remoting.UserRequest.perform(UserRequest.java:23)
      at hudson.remoting.Request$2.run(Request.java:200)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
      at java.util.concurrent.FutureTask.run(FutureTask.java:123)
      at
      java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
      at java.lang.Thread.run(Thread.java:595)


      I've found what was causing the NPE issue and have 2 possible solutions
      for it.

      =====
      Cause
      =====

      The NPE was happening on line 87 in WorkspaceScanner:

      http://fisheye5.cenqua.com/browse/hudson/hudson/plugins/tasks/src/main/java/hudson/plugins/tasks/parser/WorkspaceScanner.java?r=1.4

      87: Collection<Task> tasks = taskScanner.scan(new
      FilePath(originalFile).read());

      After debugging it turns out its because the taskScanner object is null!
      The reason is because taskScanner is defined as a transient object:

      32: @SuppressWarnings("Se")
      33: private final transient TaskScanner taskScanner;

      Therefore the object does not get serialized when the WorkspaceScanner
      object is passed over the network to the slave.

      ==========
      Solution 1
      ==========

      Make the taskScanner non-transient. I like this solution as it is
      simple, and the taskScanner should be passed along with the
      WorkspaceScanner object I think. I may be wrong of course, we would have
      to consult with the author of the plugin who is currently on vacation I
      think.

      ==========
      Solution 2
      ==========

      Instantiate the taskScanner object at the point it is needed, not in the
      constructor. This would of course mean the taskScanner member should not
      be final - or it need not be a member at all, it can be a functional
      variable. On the flip side we would have to make high, normal & low as
      member variables.


      After some discussion with Kohsuke I'll go ahead and implement solution 2. I
      emailed you Drulli but it looks like you're on vacation, hope to touch base with
      you when you're back to discuss/go over the changes.

        Attachments

          Activity

          Show
          akshay_abd akshay_abd added a comment - drulli took care of it already: http://fisheye5.cenqua.com/browse/hudson/hudson/plugins/tasks/src/main/java/hudson/plugins/tasks/parser/WorkspaceScanner.java?r1=1.4&r2=1.5

            People

            Assignee:
            akshay_abd akshay_abd
            Reporter:
            akshay_abd akshay_abd
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: