MartinBalin commented on code in PR #9650:
URL: https://github.com/apache/netbeans/pull/9650#discussion_r4158840929


##########
ide/projectapi.nb/src/org/netbeans/modules/projectapi/nb/NbProjectManager.java:
##########
@@ -250,11 +261,17 @@ public Project run() throws IOException {
                         assert !LoadStatus.LOADING_PROJECT.is(o);
                         wasSomeSuchProject = 
LoadStatus.SOME_SUCH_PROJECT.is(o);
                         if (LoadStatus.NO_SUCH_PROJECT.is(o)) {
-                            if (LOG.isLoggable(Level.FINE)) {
-                                LOG.log(Level.FINE, "findProject({0}) in {1}: 
NO_SUCH_PROJECT", new Object[] {projectDirectory, 
Thread.currentThread().getName()});
+                            if (fallback) {
+                                // treat a not checked project yet
+                                o = null;
+                            } else {
+                                if (LOG.isLoggable(Level.FINE)) {
+                                    LOG.log(Level.FINE, "findProject({0}) in 
{1}: NO_SUCH_PROJECT", new Object[]{projectDirectory, 
Thread.currentThread().getName()});
+                                }
+                                return null;
                             }
-                            return null;
-                        } else if (o != null && 
!LoadStatus.SOME_SUCH_PROJECT.is(o)) {
+                        }
+                        if (o != null && !LoadStatus.SOME_SUCH_PROJECT.is(o)) {

Review Comment:
   **Fallbacks break existing project recognition consumers**
   Once cached, a fallback is returned by ordinary findProject(). Consequently, 
FileOwnerQuery assigns previously unowned Java files to it, disabling 
single-file Run/Debug and classpath support, which require a null owner. It 
also makes ProjectGenerator.createProject() reject the folder as already 
containing a project. Preserve these existing consumers’ behavior before 
exposing fallbacks through the ordinary cache.
   
   **Cache clearing returns before replacing fallbacks under write access** — 
NbProjectManager.java (line 517)
   postReadRequest() defers execution until the current write lock is released. 
Creating project metadata, calling clearNonProjectCache(), then calling 
findProject() within that lock therefore still returns the fallback. 
Replacement needs to take effect before the subsequent lookup.
   
   **Replaced fallbacks remain valid and can retain file ownership** — 
NbProjectManager.java (line 525)
   Removal updates only dir2Proj. The fallback remains in proj2Factory, so 
isValid(fallback) stays true. When replacement is triggered by a factory lookup 
change, the file-owner cache also remains stale: findProject() returns the real 
project while FileOwnerQuery returns the fallback. Retire the old instance and 
invalidate ownership caches together.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to