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 encountered a synchronization related problem whereby code which creates a file directly in the project file system (containers) and then attempts to obtain an entry from the project environment sometimes does not succeed. The code slice is listed below. The problem appears to be in the ProjectMember.Environment.beforeLookup. The following sequence of events would cause a problem on an uninitialized project member: Thread1 beforeLookup if (getLookup().length == 0) // true // item is valid if (!environmentConstruction) environmentConstruction = true; surrenders control Thread2 beforeLookup if (getLookup().length == 0) // true // item is valid if (!environmentConstruction) returns empty lookup. I have attached a patch which passed the unit tests and resolves the problem on the target system. Example code slice. FileObject fo = containers.createData(resourceName, RESOURCE_EXT); ProjectMember pm = p.getProjectMember(fo); ResourceDescriptor resource = (ResourceDescriptor) pm.getLookup().lookup(ResourceDescriptor.class);
Created attachment 11534 [details] ProjectMember suggested fix
Thanks for good report. I already observed something similar when working with jarpackager, but haven't time to track it down. Also thanks for the patch, unfortunately I think it will cause deadlocks. There was already such kind of synchronization and I removed it because of deadlocks. The threading issues related to ProjectMembers definitely deserve some effort. I was hoping to get some aid from Jesse's Threading Model Proposal, but it seems to be still in the very early stage. So, I guess we should try to improve it on our own.
This blocking a studio milestone. I will need to apply the patch 9/10/2003 so that development can proceed.
Well, if it seems to help in your situation go ahead and apply the patch. Please, mention this issue in comment somewhere around changed code to be aware of the problem in future. I am going to propose some threading model for ProjectMembers soon and probably refactor this code. Thanks for patch anyway.
As described in http://www.netbeans.org/servlets/ReadMsg?msgId=619519&listName=nbdiscuss the current work on projects prototype has been stopped.
Marking issue as VERIFIED --->
---> CLOSED