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.
|Summary:||Registering external source roots in postWriteRequest is unreliable|
|Product:||projects||Reporter:||Jesse Glick <jglick>|
|Component:||Ant Project||Assignee:||Jesse Glick <jglick>|
|Severity:||blocker||CC:||apireviews, dkonecny, tmysik, tzezula|
|Priority:||P2||Keywords:||API, API_REVIEW_FAST, THREAD|
|Issue Type:||DEFECT||Exception Reporter:|
|Bug Depends on:||165149|
Start of a patch
Running patch... still working on this, expect to commit soon
Description Jesse Glick 2008-09-10 22:04:51 UTC
SourcesHelper.registerExternalSourceRoots Javadoc states: "You may _not_ call this method inside the project's constructor, as it requires the actual project to exist and be registered in ProjectManager. Typically you would use Mutex.postWriteRequest to run it later, if you were creating the helper in your constructor, since the project construction normally occurs in read access." Unfortunately using pWR results in strange threading behavior, including unreliable tests (see #b5f07b919bea and #abb8ce297ad9 for example). Perhaps this weirdness could be avoided if the SourcesHelper constructor took an optional Project object (with the understanding that it need not yet be registered in ProjectManager). Then it would not need to find the Project from the AntProjectHelper, which would make it possible to register the external source roots synchronously.
Comment 2 Jesse Glick 2008-09-10 22:32:21 UTC
Has been a problem since the creation of SourcesHelper.
Comment 3 David Konecny 2008-09-10 23:25:54 UTC
Well, if that's all what needs to be done to resolve this issue then I wonder why have not we done it earlier. Patch looks good to me. Thanks Jesse.
Comment 4 Jesse Glick 2008-09-11 22:38:42 UTC
I would love to have this in 6.5, but if not, then I will need to work around the timing in the Eclipse project importer: after creating a new j2seproject (or web project), it cannot immediately use ProjectClassPathModifier, as external roots will not yet be owned; it needs to delay this action using postWriteRequest (to run after the registerExternalRoots).
Comment 5 David Konecny 2008-09-11 22:45:13 UTC
Let's fix it for 6.5. Have you intentionally passed it to Milan or would you implement it yourself Jesse? If you introduce new API I'm happy to update Web/J2EE projects separately.
Comment 6 Jesse Glick 2008-09-12 17:43:54 UTC
I just passed it to Milan as default owner and to get a review. I don't mind doing the work but it seems too late to make a change like this for 6.5, isn't it?
Comment 7 Jesse Glick 2008-09-12 19:00:26 UTC
Actually it seems that this is not such a high priority; in the case of the Eclipse project import, the roots are actually registered inside the call to J2SEProjectGenerator.createProject, since we are running all this in write access: at org.netbeans.spi.project.support.ant.SourcesHelper.remarkExternalRoots(SourcesHelper.java:524) at org.netbeans.spi.project.support.ant.SourcesHelper.registerExternalRoots(SourcesHelper.java:516) at org.netbeans.modules.java.j2seproject.J2SESources$2.run(J2SESources.java:164) at org.openide.util.Mutex.leaveImpl(Mutex.java:902) at org.openide.util.Mutex.leave(Mutex.java:835) at org.openide.util.Mutex.readAccess(Mutex.java:333) at org.openide.util.Mutex$1R.run(Mutex.java:1299) at org.openide.util.Mutex.doWrapperAccess(Mutex.java:1318) at org.openide.util.Mutex.readAccess(Mutex.java:320) at org.netbeans.api.project.ProjectManager.findProject(ProjectManager.java:241) at org.netbeans.spi.project.support.ant.ProjectGenerator$1.run(ProjectGenerator.java:161) at org.netbeans.spi.project.support.ant.ProjectGenerator$1.run(ProjectGenerator.java:115) at org.openide.util.Mutex.writeAccess(Mutex.java:433) at org.openide.util.Mutex$1R.run(Mutex.java:1305) at org.openide.util.Mutex.doWrapperAccess(Mutex.java:1318) at org.openide.util.Mutex.writeAccess(Mutex.java:426) at org.netbeans.spi.project.support.ant.ProjectGenerator.createProject0(ProjectGenerator.java:114) at org.netbeans.spi.project.support.ant.ProjectGenerator.createProject(ProjectGenerator.java:108) at org.netbeans.modules.java.j2seproject.J2SEProjectGenerator.createProject(J2SEProjectGenerator.java:223) There seems to be some other problem making Eclipse import with external roots be broken, but I am still investigating what that might be.
Comment 8 Jesse Glick 2009-01-09 18:06:08 UTC
*** Issue 142938 has been marked as a duplicate of this issue. ***
Comment 9 Jesse Glick 2009-01-09 18:13:40 UTC
Lack of this seems to prevent a simple-looking patch to projectimport.eclipse.core from working (an AE is thrown similar to issue #142938 when you try to import a project). I will attach that patch here.
Comment 11 Antonin Nebuzelsky 2009-03-20 16:19:56 UTC
Reassigning to Jesse.
Comment 13 Jesse Glick 2009-03-20 22:08:14 UTC
Comment 14 Jesse Glick 2009-04-01 22:04:33 UTC
Created attachment 79246 [details] Running patch... still working on this, expect to commit soon
Comment 15 Jesse Glick 2009-04-02 22:39:18 UTC
Comment 16 Quality Engineering 2009-04-03 20:00:45 UTC
Integrated into 'main-golden', will be available in build *200904031400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/23a442bff758 User: Jesse Glick <email@example.com> Log: Issue #146852: accept Project in a constructor for SourcesHelper to permit registerExternalRoots to run synch. Can help simplify tests, and makes control flow easier to understand and debug. Also taking advantage of synchronous control flow to optimize class loading in the Eclipse importer.
Comment 17 Jesse Glick 2009-04-17 17:19:33 UTC
*** Issue 154263 has been marked as a duplicate of this issue. ***