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.
The org.netbeans.api.project.ProjectManager (PM) looks like a controller, which should caching and loading projects. It has the function findProject(projectDirectory). It is expected (according to common sense) it provides the same Project by the same project's folder. But unfortunately it works not very reliable way. Sometimes PM can cache more then one instance of the same project. It can lead to unexpected errors at different places. Actually I faced with problem (issue #148288) which made me investigate a bit. The reason of the described problem is the FileObject class. It doesn't redefine the equals() and hashCode() methods. The FileObject (project directory) is used as a key in a HashSet. The HashSet (dir2Proj) is the main container for caching projects in PM.
I tried experimenting with sources in scope of the issue #148288. I used the sources from netbeans61_fixes branch. It seems the same problem exists in the trunk branch. I think the real problem locates not in the ProjectManager but rather in the FileObject. I added (locally) equals() and hashCode() methods to the FileObject and BaseFileObj classes and it helps in my case: org.openide.filesystems.FileObject; protected static boolean equal(Object o1, Object o2) { if (o1 == o2) return true; return (o1 == null || o2 == null) ? false : o1.equals(o2); } @Override public int hashCode() { return toString().hashCode(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; // if (obj instanceof FileObject) { String otherFile = ((FileObject)obj).toString(); return equal(this.toString(), otherFile); } // return super.equals(obj); } org.netbeans.modules.masterfs.filebasedfs.fileobjects.BaseFileObj; @Override public int hashCode() { return this.fileName.getFile().hashCode(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; // if (obj instanceof BaseFileObj) { File otherFile = ((BaseFileObj)obj).getFileName().getFile(); return equal(this.fileName.getFile(), otherFile); } // return super.equals(obj); } Eventually I don't insist FileObject should redefine equals method. But the ProjectManager should be smart enough to prevent duplicate caching when it get different instances of FileObject which both pointing to the same folder. That is why I filed the issue to this category.
BTW, after my local changes with FileObject I found that Project Manager works as I expected and it seems NetBeans works a little bit faster. Maybe it is only my feelings. Also I hope more predictable work of Project Manager can fix some other issues which have not been found yet.
AFAIK the contract of FileObject is that as long as the FileObject is no GC-ed, always the same instance is returned for a given file. reassigning to filesystems
Could you attach some reproducable test?
I didn't write a special test. I tried to fix the issue #148289. So you can try using the steps described there. Be aware that the 148289 doesn't reproduced in NetBeans 6.5. But it doesn't mean that everything Ok there. Please see description of the 148289
Ask me if you have any questions with reproducing the 148289
I tried to follow steps in issue 148289 but when I click Mapper button it says "Unable to show bpel mapper. The bpel mapper is not required for the (newProcess [Process]) activity.". So far, I don't know how failure on screen shot can be connected with ProjectManager. Please, give me either unit test or steps how to reproduce the failure and pointers to bpel code which calls ProjectManager and which is involved according to your investigation. Thank you in advance. Product Version: NetBeans IDE 6.1 (Build 200804211638) Java: 1.6.0_10; Java HotSpot(TM) Client VM 11.0-b15 System: Windows XP version 5.1 running on x86; Cp1250; cs_CZ (nb)
Oh. Big sorry that I confused you. The issue number was a bit incorrect. :-( You should use the 148288 instead.
invalid. the most likely cause of the issue in bpel project is similar to what was happening in swing app projhect template in issue http://www.netbeans.org/issues/show_bug.cgi?id=129405. http://hg.netbeans.org/main/rev/e150f0d43ac6
I agree it should be fixed in Bpel project because other projects like J2SE or web project work without problems.
I agree that the problem isn't clear enough. Also it is difficult to reproduce it because it doesn't appear at NetBeans 6.5 main branch. But it has not been proved that the real problem somewhere in the BPEL project. The bug #148288 well reproduced in the soa-dev branch, so I'm going to continue investigating and maybe reopen this issue later if I get additional evidences.