eirikbakke commented on code in PR #8171:
URL: https://github.com/apache/netbeans/pull/8171#discussion_r1922723248


##########
ide/projectui/src/org/netbeans/modules/project/ui/ProjectUtilities.java:
##########
@@ -135,28 +130,23 @@ private void doClose(Project[] projects, boolean 
notifyUI, Wrapper wr) {
                 if (dobj != null) {
                     FileObject fobj = dobj.getPrimaryFile();
                     Project owner = 
ProjectConvertors.getNonConvertorOwner(fobj);
-                    ERR.log(Level.FINER, "Found {0} owned by {1} in {2} of 
{3}", new Object[] {fobj, owner, tc.getName(), tc.getClass()});
+                    LOG.log(Level.FINER, "Found {0} owned by {1} in {2} of 
{3}", new Object[] {fobj, owner, tc.getName(), tc.getClass()});
 
-                    if (listOfProjects.contains(owner)) {
+                    Set<String> files = project2FilesMap.get(owner);
+                    if (files != null) {
                         if (notifyUI) {
                             openFiles.add(dobj);
                             tc2close.add(tc);
                         } else if (!dobj.isModified()) {
                             // when not called from UI, only include TCs that 
arenot modified
                             tc2close.add(tc);
                         }
-                        //#235897 split a single line to detect NPE better
-                        final Set<String> pwnr = wr.urls4project.get(owner);
-                        assert pwnr != null : "Owner project for file:" + fobj 
+ " prj:" + owner;
-                        final FileObject pf = fobj;
-                        assert pf != null;
-                        URL u = pf.toURL();
-                        assert u != null;
-                        String uex = u.toExternalForm();                       
 
-                        pwnr.add(uex);
+                        files.add(fobj.toURL().toExternalForm());
+                    } else {
+                        LOG.log(Level.WARNING, "project association lost, 
project ({1}) might lose an opened file ({2}) on reopen", new Object[] {owner, 
fobj});

Review Comment:
   Sorry, one more case to ask about...
   
   What about files that are not associated with a project? E.g. if you open a 
file not in a project with "Open File" in the "File" menu. Does 
ProjectConvertors.getNonConvertorOwner(fobj) return null in that case? The loop 
should probably quietly skip such files without closing them or logging a 
warning.
   
   (Sorry I didn't see this earlier...)



-- 
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