You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/05/05 20:09:12 UTC

[GitHub] [solr] dsmiley commented on a diff in pull request #818: SOLR-16163: Review unintended try-with-resources closing-order modifications

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


##########
solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java:
##########
@@ -274,6 +273,11 @@ public void writeResults(ResultContext ctx, JavaBinCodec codec) throws IOExcepti
         req.close();
         SolrRequestInfo.clearRequestInfo();
       }
+      // NOTE: `req` must be closed _before_ core, because `req` can hold a reference to
+      // SolrIndexSearcher which can in some cases block `core.close()` from completing
+      // successfully (by holding a reference to a core Directory). Hence we cannot trivially
+      // use try-with-resources to close `core`.
+      core.close();

Review Comment:
   Yes I agree; I think we should embrace try-with-resources as it provides structure.



-- 
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-unsubscribe@solr.apache.org

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


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