Copilot commented on code in PR #4225:
URL: https://github.com/apache/solr/pull/4225#discussion_r2956914750


##########
solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java:
##########
@@ -83,7 +83,7 @@ static Path determineSourceHome() {
       }
 
       Path base = file.toAbsolutePath();
-      while (!Files.exists(base.resolve("solr/test-framework/build.gradle")) 
&& null != base) {
+      while (null != base && 
!Files.exists(base.resolve("solr/test-framework/build.gradle"))) {

Review Comment:
   Reordering the `&&` avoids the NPE inside this loop, but it also makes it 
more likely `determineSourceHome()` returns `null` when no suitable base 
directory is found. In that case, the class still throws an NPE during static 
initialization because `WEBAPP_HOME`/`DEFAULT_CONFIGSET`/etc call 
`SOURCE_HOME.resolve(...)` unconditionally. To actually fix the "NPE on class 
init" scenario, the derived static paths need to be guarded (e.g., initialize 
them to `null` when `SOURCE_HOME` is null, or compute them lazily via methods 
that return null/Optional).



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

Reply via email to