eppleton commented on code in PR #9650:
URL: https://github.com/apache/netbeans/pull/9650#discussion_r4155877737
##########
ide/projectapi.nb/src/org/netbeans/modules/projectapi/nb/NbProjectManager.java:
##########
@@ -489,11 +513,28 @@ public void clearNonProjectCache() {
LoadStatus.NO_SUCH_PROJECT.wrap(),
LoadStatus.SOME_SUCH_PROJECT.wrap(),
}));
- // XXX remove everything too? but then e.g.
AntProjectFactorySingleton
- // will stay while its delegates are changed, which does no good
- // XXX should there be any way to signal that a particular
- // folder should be "reloaded" by a new factory?
}
+ MUTEX.postReadRequest(() -> {
Review Comment:
When a real project later appears in a fallback's folder, the switch here
doesn't fully happen. Two tests on this branch:
```java
public void testFallbackReplacedAfterClearNonProjectCacheUnderWriteAccess()
throws Exception {
Project fallback = pm.findProjectOrFallback(justADir);
Project real =
ProjectManager.mutex().writeAccess((Mutex.ExceptionAction<Project>) () -> {
// what project generators do: create metadata, clear cache, find
project
justADir.createFolder("testproject");
pm.clearNonProjectCache();
return pm.findProject(justADir);
});
assertNotNull(real);
assertNotSame("Real project replaces the fallback", fallback, real);
// fails
}
public void testReplacedFallbackIsNoLongerValid() throws Exception {
Project fallback = pm.findProjectOrFallback(justADir);
justADir.createFolder("testproject");
pm.clearNonProjectCache();
Project real = pm.findProject(justADir);
assertNotSame(fallback, real);
assertFalse("Replaced fallback should not be valid anymore",
pm.isValid(fallback)); // fails
}
```
1. Under write access `postReadRequest` is deferred, so `findProject` right
after `clearNonProjectCache()` still returns the fallback. Ant's
`ProjectGenerator.createProject` does exactly this inside `writeAccess`. It
then calls `getHelperFor(p)` and would throw "was not recognized as an
Ant-based project" when creating a project in a folder that is open as a
fallback.
2. The entry is only removed from `dir2Proj`. `proj2Factory` still holds the
fallback and `callBack.notifyDeleted` isn't called, so `isValid(fallback)`
stays true and the open fallback never learns it was replaced.
One option might be to check, in `findProjectImpl`, whether a cached
`FallbackProject` should give way to a real project (and retire it via the
`notifyDeleted` path), instead of doing it asynchronously here. Happy to help
with that.
--
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