You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/06/17 18:09:45 UTC

[GitHub] [netbeans] errael commented on a diff in pull request #4236: Avoid NPE in ant module suite's "Project Properties" dialog.

errael commented on code in PR #4236:
URL: https://github.com/apache/netbeans/pull/4236#discussion_r900403943


##########
apisupport/apisupport.ant/src/org/netbeans/modules/apisupport/project/universe/ClusterUtils.java:
##########
@@ -169,8 +169,11 @@ public static Set<ClusterInfo> evaluateClusterPath(File root, PropertyEvaluator
                     prj = _prj;
                 } else {
                     NbModuleProvider prov2 = _prj.getLookup().lookup(NbModuleProvider.class);
-                    if (prov2 != null && /* XXX is there a better way? */ cd.equals(prov2.getModuleJarLocation().getParentFile().getParentFile())) {
-                        prj = _prj;
+                    if (prov2 != null) {
+                        File fi = prov2.getModuleJarLocation();
+                        if (fi != null && /* XXX is there a better way? */ cd.equals(fi.getParentFile().getParentFile())) {

Review Comment:
   Technically yes; but no, not really. The contract is that a returned File is somewhere inside a project, it's parent can't be null.
   
   For example, elsewhere in `ClusterUtils` there's
   ```
               File jar = nbmp.getModuleJarLocation();
               if (jar != null) {
                   return jar.getParentFile().getParentFile();
               }
   ```
   There are other examples scattered through other files.



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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