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


##########
ide/projectui/src/org/netbeans/modules/project/ui/groups/Group.java:
##########
@@ -562,7 +562,15 @@ static void open(final Group g, String oldGroupName, 
boolean isNewGroup, Prefere
             h.start(200);
             ProjectUtilities.WaitCursor.show();
             final OpenProjectList opl = OpenProjectList.getDefault();
-            Set<Project> oldOpen = new 
HashSet<Project>(Arrays.asList(opl.getOpenProjects()));
+            
+            Set<Project> oldOpen = new HashSet<>();
+            for (Project open : Arrays.asList(opl.getOpenProjects())) {
+                // TODO fix this properly
+                // unbox potential fod.FeatureNonProject wrapper since it 
breaks Sets/Maps due to incompatible hashcode impls
+                Project real = open.getLookup().lookup(Project.class);
+                oldOpen.add(real != null ? real : open);
+            }
+

Review Comment:
   > The TODO comment would be improved by suggesting what the proper fix might 
look like.
   
   IMO: the proper fix would be to repair equals/hashcode. Once done 
`opl.getOpenProjects()` should be changed to return only unboxed projects - 
since I don't think projects can be open without their cluster loaded.
   
   However: realistically, I am not sure if this can be done at this point 
since it is quite risky. The getter is exposed via public API and fixing object 
identity mechanics could break other things, given how many workaround already 
exist (e.g the `a.equals(b) || b.equals(a)` situation). If at all this must be 
done carefully and might need some refactoring first before attempting it.
   
   edit: updated comment



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