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

Disk usage pluging detect Null pointer exception

    Details

    • Similar Issues:

      Description

      Stack trace find out from the Jenkin's log:
      java.lang.NullPointerException
      at hudson.plugins.disk_usage.DiskUsageThread$DiskUsageCallable.getFileSize(DiskUsageThread.java:161)
      at hudson.plugins.disk_usage.DiskUsageThread$DiskUsageCallable.getFileSize(DiskUsageThread.java:162)
      at hudson.plugins.disk_usage.DiskUsageThread$DiskUsageCallable.getFileSize(DiskUsageThread.java:162)
      at hudson.plugins.disk_usage.DiskUsageThread$DiskUsageCallable.getFileSize(DiskUsageThread.java:162)
      at hudson.plugins.disk_usage.DiskUsageThread$DiskUsageCallable.call(DiskUsageThread.java:154)
      at hudson.plugins.disk_usage.DiskUsageThread$DiskUsageCallable.call(DiskUsageThread.java:144)
      at hudson.FilePath.act(FilePath.java:784)
      at hudson.plugins.disk_usage.DiskUsageThread.calculateWorkspaceDiskUsage(DiskUsageThread.java:127)
      at hudson.plugins.disk_usage.DiskUsageThread.execute(DiskUsageThread.java:78)
      at hudson.model.AsyncPeriodicWork$1.run(AsyncPeriodicWork.java:51)
      at java.lang.Thread.run(Thread.java:636)

        Attachments

          Activity

          Hide
          rioch rioch added a comment -

          I'm also seeing this in my log files.

          Show
          rioch rioch added a comment - I'm also seeing this in my log files.
          Hide
          vjuranek vjuranek added a comment -

          do you see it regularly? Any idea, how to reproduce it? Thanks

          Show
          vjuranek vjuranek added a comment - do you see it regularly? Any idea, how to reproduce it? Thanks
          Hide
          oldelvet Richard Mortimer added a comment -

          I am getting the same error in my jenkins.log file.

          I added some diagnostics into disk-usage.hpi and have worked out what is happening. The primary cause of the NPE is that f.listFiles() at line 161 of DiskUsageThread.java returns null.

          https://github.com/jenkinsci/disk-usage-plugin/blob/master/src/main/java/hudson/plugins/disk_usage/DiskUsageThread.java

          Unwinding what goes on it seems that some folders in the project workspace are not accessible by the Jenkins user and this causes null to be returned by listFiles.

          In my case this is happening because one of my project's builds has its build.xml <workspace> element set to / and hence it tries to walk my servers full filesystem. Needless to say it soon walks into a folder that is not readable and the NPE arises.

          As an example the build.xml file contained

          <workspace>/</workspace>

          I'm not sure why workspace was / but the same build.xml file says that the build was done with hudson 1.393 and the build is dated January

          <hudsonVersion>1.393</hudsonVersion>

          I have a trace of it walking the filesystem but it is quite large and it does go wrong just as it tries to walk into /lost+found

          A minimal "fix" for this is to check whether listfiles() returns null. I've tested that and it makes my system work ok. I have also manually edited the broken build.xml files and confirmed to give a valid workspace pathname.

          It maybe that the best way to handle the problem is to catch the null listfiles result and just log that the folder could not be examined. That might cause a large log though.

          Show
          oldelvet Richard Mortimer added a comment - I am getting the same error in my jenkins.log file. I added some diagnostics into disk-usage.hpi and have worked out what is happening. The primary cause of the NPE is that f.listFiles() at line 161 of DiskUsageThread.java returns null. https://github.com/jenkinsci/disk-usage-plugin/blob/master/src/main/java/hudson/plugins/disk_usage/DiskUsageThread.java Unwinding what goes on it seems that some folders in the project workspace are not accessible by the Jenkins user and this causes null to be returned by listFiles. In my case this is happening because one of my project's builds has its build.xml <workspace> element set to / and hence it tries to walk my servers full filesystem. Needless to say it soon walks into a folder that is not readable and the NPE arises. As an example the build.xml file contained <workspace>/</workspace> I'm not sure why workspace was / but the same build.xml file says that the build was done with hudson 1.393 and the build is dated January <hudsonVersion>1.393</hudsonVersion> I have a trace of it walking the filesystem but it is quite large and it does go wrong just as it tries to walk into /lost+found A minimal "fix" for this is to check whether listfiles() returns null. I've tested that and it makes my system work ok. I have also manually edited the broken build.xml files and confirmed to give a valid workspace pathname. It maybe that the best way to handle the problem is to catch the null listfiles result and just log that the folder could not be examined. That might cause a large log though.
          Hide
          oldelvet Richard Mortimer added a comment -

          I have packaged my suggested fix and it is included in pull request

          https://github.com/jenkinsci/disk-usage-plugin/pull/3

          Show
          oldelvet Richard Mortimer added a comment - I have packaged my suggested fix and it is included in pull request https://github.com/jenkinsci/disk-usage-plugin/pull/3
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Richard Mortimer
          Path:
          src/main/java/hudson/plugins/disk_usage/DiskUsageThread.java
          http://jenkins-ci.org/commit/disk-usage-plugin/f1bf0389649150131b31b69ce9bd209584295416
          Log:
          JENKINS-8844 Disk usage plugin detect Null pointer exception
          Ignore folders where the content files cannot be listed.
          Any ignored folders are logged to make resolution easier.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Richard Mortimer Path: src/main/java/hudson/plugins/disk_usage/DiskUsageThread.java http://jenkins-ci.org/commit/disk-usage-plugin/f1bf0389649150131b31b69ce9bd209584295416 Log: JENKINS-8844 Disk usage plugin detect Null pointer exception Ignore folders where the content files cannot be listed. Any ignored folders are logged to make resolution easier.
          Hide
          vjuranek vjuranek added a comment -

          Should be fixed now, if not, please reopen.

          Show
          vjuranek vjuranek added a comment - Should be fixed now, if not, please reopen.

            People

            • Assignee:
              vjuranek vjuranek
              Reporter:
              tapiomtr tapiomtr
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: