Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oldelvet committed Jun 25, 2011
1 parent f057610 commit f1bf038
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/java/hudson/plugins/disk_usage/DiskUsageThread.java
Expand Up @@ -17,6 +17,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* A Thread responsible for gathering disk usage information
Expand Down Expand Up @@ -143,6 +144,9 @@ private static void calculateWorkspaceDiskUsage(AbstractProject project) throws
*/
public static class DiskUsageCallable implements Callable<Long, IOException> {

public static final Logger LOGGER = Logger
.getLogger(DiskUsageCallable.class.getName());

private FilePath path;

public DiskUsageCallable(FilePath filePath) {
Expand All @@ -158,9 +162,14 @@ public static Long getFileSize(File f) throws IOException {
long size = 0;

if (f.isDirectory() && !Util.isSymlink(f)) {
for (File child : f.listFiles()) {
size += getFileSize(child);
}
File[] fileList = f.listFiles();
if (fileList != null) {
for (File child : fileList) {
size += getFileSize(child);
}
} else {
LOGGER.info("Failed to list files in " + f.getPath() + " - ignoring");
}
}

return size + f.length();
Expand Down

0 comments on commit f1bf038

Please sign in to comment.