dsmiley commented on code in PR #1302:
URL: https://github.com/apache/solr/pull/1302#discussion_r1080640747


##########
solr/core/src/java/org/apache/solr/core/SolrConfig.java:
##########
@@ -393,14 +393,22 @@ private SolrConfig(
   }
 
   private IndexSchemaFactory.VersionedConfig readXml(SolrResourceLoader 
loader, String name) {
+    InputStream in = null;
     try {
-      ResourceProvider rp = new ResourceProvider(loader, name);
+      in = loader.openResource(name);
+      ResourceProvider rp = new ResourceProvider(in);
       XmlConfigFile xml = new XmlConfigFile(loader, rp, name, null, 
"/config/", null);
       return new IndexSchemaFactory.VersionedConfig(
           rp.zkVersion,
           new DataConfigNode(new 
DOMConfigNode(xml.getDocument().getDocumentElement())));
     } catch (IOException e) {
       throw new SolrException(ErrorCode.SERVER_ERROR, e);
+    } finally {
+      // according to spec, XML parser should close InputStream when parsing 
is complete.
+      // But in the event that this doesn't happen (either because an 
exception is
+      // thrown or because of an error in parser implementation, here we 
ensure that it
+      // is closed.

Review Comment:
   BTW I appreciate code comments but I don't think you need to be so wordy to 
justify closing ourselves.  IMO this can be summarized to one line:
   > XML Parser *should* close but in exceptional cases might not; so let's be 
safe



-- 
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: issues-unsubscr...@solr.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to