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.

Bug 29701 - Invalid behavior when using URLMapper
Summary: Invalid behavior when using URLMapper
Status: VERIFIED INVALID
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 3.x
Hardware: All All
: P1 blocker (vote)
Assignee: rmatous
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-12-23 19:25 UTC by Chris Webster
Modified: 2008-12-22 19:40 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
diff (1016 bytes, patch)
2003-01-27 11:23 UTC, Jan Pokorsky
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Webster 2002-12-23 19:25:30 UTC
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.
Comment 1 Chris Webster 2003-01-10 20:10:28 UTC
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. 
Comment 2 Jan Pokorsky 2003-01-27 11:21:17 UTC
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?
Comment 3 Jan Pokorsky 2003-01-27 11:23:56 UTC
Created attachment 8681 [details]
diff
Comment 4 rmatous 2003-01-27 14:05:40 UTC
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 ());
Comment 5 Chris Webster 2003-01-30 17:31:42 UTC
The suggested solution solves the problem. 
Comment 6 _ ttran 2003-01-31 11:08:15 UTC
Does it mean we can close this issue as INVALID and improve the
documentation?
Comment 7 rmatous 2003-01-31 12:29:44 UTC
Documentation changed. 
/cvs/openide/src/org/openide/filesystems/Repository.java,v  <-- 
Repository.java
new revision: 1.47; previous revision: 1.46

Marked as INVALID.
Comment 8 Marian Mirilovic 2003-07-24 08:52:23 UTC
Documentation changed - verifying.