Hi All,
I am getting an NPE in the following line of code, and I think it must be
thread related or something. More on that in a sec.
In this code within Chainsaw v2, the line highlighted:
FileObject[] fos = vfsNode.getFileObject().getChildren();
Collection objects = new ArrayList(Arrays.asList(fos));
for (Iterator iter = objects.iterator(); iter.hasNext();) {
FileObject fo = (FileObject) iter.next();
**** if(fo.getType().hasChildren()) {
iter.remove();
}
}
I get a stack trace:
java.lang.NullPointerException
at
org.apache.commons.vfs.provider.AbstractFileObject.getChildren(AbstractFileO
bject.java:478)
at org.apache.log4j.chainsaw.vfs.VFSPlugin$2.run(VFSPlugin.java:255)
at java.lang.Thread.run(Unknown Source)
If I debug, and place and break point on this line and step over, it all
works fine. Only when NOT debugging.
The line in question appears to be:
public FileObject[] getChildren() throws FileSystemException
{
attach();
**** if (!type.hasChildren())
{
throw new
FileSystemException("vfs.provider/list-children-not-folder.error", name);
}
The particular FileObject that seems to die on me is actually a locally
mapped Windows share drive. I am getting all the Root drives in the local
filesystem with the following code:
File[] roots = File.listRoots();
for (int i = 0; i < roots.length; i++) {
File root = roots[i];
// Add the authors of the java.io.File class to the list of people
to "have a word" with... This is ridiculous...
if (!(root.getAbsolutePath().toLowerCase().startsWith("a:") ||
root.getAbsolutePath().toLowerCase().startsWith("b:"))) {
if(root.exists() && root.canRead()) {
FileObject fileObject = this.fileSystemManager
.resolveFile(root.toURL().toExternalForm());
DefaultMutableTreeNode node = this.fileSystemTree
.addFileObject("local:" + root.getAbsolutePath(),
fileObject);
USER_MESSAGE_LOGGER.info("Adding " +
root.getAbsolutePath());
}
}
}
[sidenote: that I can't work out how to stop Java from polling the floppy
drives and causing an error, any clues welcome]
My "H:" drive is a windows domain mapped drive. Looks like there might be
some timing issue between the population of the type property of the
FileObject, but it only happens on these mapped drives, and ONLY when I am
not debugging through it.
Anyone seen anything like this?
cheers,
Paul Smith
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]