Copilot commented on code in PR #3696:
URL: https://github.com/apache/solr/pull/3696#discussion_r2378822168
##########
solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java:
##########
@@ -374,7 +375,8 @@ public static Path getAdminFileFromFileSystem(
if (!Files.exists(configDir)) {
// TODO: maybe we should just open it this way to start with?
try {
- configDir =
Path.of(loader.getClassLoader().getResource(loader.getConfigDir()).toURI());
+ URL configUrl =
loader.getClassLoader().getResource(loader.getConfigPath().toString());
Review Comment:
Potential null pointer exception if `getResource()` returns null. The
original code would have thrown a NullPointerException on the `toURI()` call,
but now it will fail on `configUrl.toURI()`. Consider adding a null check for
`configUrl` before calling `toURI()`.
```suggestion
URL configUrl =
loader.getClassLoader().getResource(loader.getConfigPath().toString());
if (configUrl == null) {
log.error("Configuration directory resource not found: {}",
loader.getConfigPath().toString());
rsp.setException(
new SolrException(
SolrException.ErrorCode.FORBIDDEN, "Configuration
directory resource not found: " + loader.getConfigPath().toString()));
return null;
}
```
--
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]