madrob commented on code in PR #962:
URL: https://github.com/apache/solr/pull/962#discussion_r937752934


##########
solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java:
##########
@@ -376,19 +375,19 @@ protected long getConfigVersion(SolrCore core) {
    *
    * @return The loaded {@link ElevationProvider}; not null.
    */
-  private ElevationProvider loadElevationProvider(SolrCore core) throws 
Exception {
-    XmlConfigFile cfg;
-    try {
-      cfg = new XmlConfigFile(core.getResourceLoader(), configFileName);
+  private ElevationProvider loadElevationProvider(SolrCore core) throws 
IOException, SAXException {
+    try (var inputStream = 
core.getResourceLoader().openResource(configFileName)) {
+      return Objects.requireNonNull(
+          loadElevationProvider(SafeXMLParsing.parseUntrustedXML(log, 
inputStream)));
     } catch (SolrResourceNotFoundException e) {
-      String msg = "Missing config file \"" + configFileName + "\"";
+      var msg = "Missing config file \"" + configFileName + "\"";
       if (Files.exists(Path.of(core.getDataDir(), configFileName))) {
         msg += ". Found it in the data dir but this is no longer supported 
since 9.0.";
       }
       throw new InitializationException(msg, 
InitializationExceptionCause.MISSING_CONFIG_FILE);
     } catch (Exception e) {
       // See if it's because the file is empty; wrap it if so.
-      boolean isEmpty = false;

Review Comment:
   This is a stylistic choice but I don't think we should replace primitives 
with vars. Would prefer to see this PR making a more minimal change set rather 
that re-typing a bunch of variables.
   
   I know that @dsmiley is a big proponent of var, so I could be convinced if I 
understood better what's the benefit here?



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