This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I have a unit test which executes code similar to the following: FileObject fo = projectFolder.getPrimaryFile().createData("file", "ext"); MutableFileSet mfs = FileSets.createFileObjectSet(false, ReferenceResolver.getDefault()); mfs.add(fo); Iterator it = FileSets.createFileObjectSet(mfs, false).iterator(); while (it.hasNext()) { Object fobj = it.next(); log(fobj.toString()); log(fobj.getClass().getName()); } The body of the iterator loop is never executed, because the file cannot be resolved.
I integrated into org.netbeans.spi.compilation.TimestampContextTest a demonstration of the failure (beginning around line 89). This test can be executed in the projects/compilation module.
Chris, it seems it is bug of URLMapper. It is not able to resolve URL back to FileObject. See the diff of the test. The problem could be in read-only LocalFileSystem created with Utils.getProjectFolder. Radku, can you shed light on that?
Created attachment 8681 [details] diff
Investigated with Jan. Result: problem is not in URLMapper, but in setUp code of test. But I must admit, that method Repository.addFileSystem is not transparent enough and is not well documented. Description of problem: Probem is in method Utils.getProjectFolder. There is problem, that exist two LocalFileSystems with the same systemName. One is in Repository (lfs1) and second one isn't (lfs2). You create new resource using createData on lfs2. If you look for resource in Repository (which is called from URLMapper), then lfs1 may not know nothing about resource until refreh on lfs1 is invoked. Simplified from Utils.getProjectFolder: lfs = new LocalFS (); lfs.setRootDirectory (..); Repository.addFileSystem (lfs); Here you consider lfs to be added in Repository. But if there already existed some FileSystem with the same name in Repository, then lfs is not really added, which is our case. Please change code: lfs = new LocalFS (); lfs.setRootDirectory (..); Repository.addFileSystem (lfs); if (!lfs.isValid ()) lfs = lfs.findFileSystem (lfs.getSystemNaem ());
The suggested solution solves the problem.
Does it mean we can close this issue as INVALID and improve the documentation?
Documentation changed. /cvs/openide/src/org/openide/filesystems/Repository.java,v <-- Repository.java new revision: 1.47; previous revision: 1.46 Marked as INVALID.
Documentation changed - verifying.