This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 263b92261c4 SOLR-17629: SQLHandler: remember to close if open fails 
(#3045)
263b92261c4 is described below

commit 263b92261c4eb01b70c3d858b130ecf19bdcc023
Author: David Smiley <[email protected]>
AuthorDate: Wed Jan 22 01:30:09 2025 -0500

    SOLR-17629: SQLHandler: remember to close if open fails (#3045)
    
    (cherry picked from commit e91e8dcd31ff458c7425e989a397cdd30cf8da59)
---
 solr/CHANGES.txt                                                       | 3 +++
 .../sql/src/java/org/apache/solr/handler/sql/SolrEnumerator.java       | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index c571e4fe716..c173eb21d5b 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -34,6 +34,9 @@ Bug Fixes
   doing distributed search (sharded collections). This could likely occur for 
fielded parameters such as
   f.CASE_SENSITIVE_FIELD.facet.limit=50. (Yue Yu, David Smiley)
 
+* SOLR-17629: If SQLHandler failed to open the underlying stream (e.g. Solr 
returns an error; could be user/syntax problem),
+  it needs to close the stream to cleanup resources but wasn't. (David Smiley)
+
 Dependency Upgrades
 ---------------------
 * SOLR-17471: Upgrade Lucene to 9.12.1. (Pierre Salagnac, Christine Poerschke)
diff --git 
a/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrEnumerator.java 
b/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrEnumerator.java
index 6ec89172b2d..ba4a06bafbf 100644
--- a/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrEnumerator.java
+++ b/solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrEnumerator.java
@@ -24,6 +24,7 @@ import java.util.Map;
 import org.apache.calcite.linq4j.Enumerator;
 import org.apache.solr.client.solrj.io.Tuple;
 import org.apache.solr.client.solrj.io.stream.TupleStream;
+import org.apache.solr.common.util.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -42,11 +43,11 @@ class SolrEnumerator implements Enumerator<Object> {
    * @param fields Fields to get from each Tuple
    */
   SolrEnumerator(TupleStream tupleStream, List<Map.Entry<String, Class<?>>> 
fields) {
-
     this.tupleStream = tupleStream;
     try {
       this.tupleStream.open();
     } catch (IOException e) {
+      IOUtils.closeQuietly(tupleStream);
       throw new RuntimeException(e);
     }
     this.fields = fields;

Reply via email to