? projectapi/lib Index: projectapi/src/org/netbeans/api/project/ProjectManager.java =================================================================== RCS file: /cvs/projects/projectapi/src/org/netbeans/api/project/ProjectManager.java,v retrieving revision 1.35 diff -u -r1.35 ProjectManager.java --- projectapi/src/org/netbeans/api/project/ProjectManager.java 4 Sep 2007 21:40:41 -0000 1.35 +++ projectapi/src/org/netbeans/api/project/ProjectManager.java 6 Sep 2007 12:28:25 -0000 @@ -149,11 +149,7 @@ /** * Whether this thread is currently loading a project. */ - private ThreadLocal loadingThread = new ThreadLocal() { - protected @Override Boolean initialValue() { - return false; - } - }; + private ThreadLocal> loadingThread = new ThreadLocal>(); /** * Clear internal state. @@ -209,7 +205,8 @@ o = dir2Proj.get(projectDirectory); if (LoadStatus.LOADING_PROJECT.is(o)) { try { - if (loadingThread.get()) { + Set ldng = loadingThread.get(); + if (ldng != null && ldng.contains(projectDirectory)) { throw new IllegalStateException("Attempt to call ProjectManager.findProject within the body of ProjectFactory.loadProject (hint: try using ProjectManager.mutex().postWriteRequest(...) within the body of your Project's constructor to prevent this)"); // NOI18N } LOG.log(Level.FINE, "findProject({0}) in {1}: waiting for LOADING_PROJECT...", new Object[] {projectDirectory, Thread.currentThread().getName()}); @@ -234,7 +231,12 @@ } // not in cache dir2Proj.put(projectDirectory, LoadStatus.LOADING_PROJECT.wrap()); - loadingThread.set(true); + Set ldng = loadingThread.get(); + if (ldng == null) { + ldng = new HashSet(); + loadingThread.set(ldng); + } + ldng.add(projectDirectory); LOG.log(Level.FINE, "findProject({0}) in {1}: will load new project...", new Object[] {projectDirectory, Thread.currentThread().getName()}); } boolean resetLP = false; @@ -266,7 +268,7 @@ // called again (without anything being GC'd) throw e; } finally { - loadingThread.set(false); + loadingThread.get().remove(projectDirectory); if (!resetLP) { // IOException or a runtime exception interrupted. LOG.log(Level.FINE, "findProject({0}) in {1}: cleaning up after error", new Object[] {projectDirectory, Thread.currentThread().getName()});