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


##########
java/gradle.java/src/org/netbeans/modules/gradle/java/spi/support/JavaToolchainSupport.java:
##########
@@ -67,11 +73,21 @@ public static JavaToolchainSupport getDefault() {
      * @return the {@linkplain JavaPlatform} representing the given directory.
      */
     public JavaPlatform platformByHome(File home) {
-        return platformCache.computeIfAbsent(home, this::detectPlatform);
+        JavaPlatform ret = platformCache.get(home);
+        if (ret == null) {
+            ret = detectPlatform(home);
+            if (ret.isValid()) {
+                platformCache.put(home, ret);
+            }
+        }
+        return ret;
     }
     
     private JavaPlatform detectPlatform(File home) {
         FileObject h = FileUtil.toFileObject(home);
+        if (h == null) {
+            return new BrokenJavaPlatform(toolchainName(home));
+        }

Review Comment:
   can this return `null`?. Going through the stack of the exception, the 
caller in `BootClassPathImpl` is dealing with null platforms already - this 
method here can also return null under certain conditions. Valid/Broken and 
null is too much IMO, valid+null should be hopefully sufficient.
   
   I don't like the concept of `BrokenPlatform` on this level since there 
already is the half-working `isValid()` in the API. Whats missing is a 
validating and not-validating factory method (or something equivalent).
   
   We have to revisit the API at some point and fix it since it has multiple 
issues, e.g https://github.com/apache/netbeans/issues/6568



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