From ab03362217d552becb3b2c87a5087deb53e0c831 Mon Sep 17 00:00:00 2001 From: David Smiley Date: Sat, 18 Jan 2025 14:54:14 -0500 Subject: [PATCH] SOLR-17629: SQLHandler: remember to close if open fails --- solr/CHANGES.txt | 3 +++ .../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 5be26c0d743..5fa74d08813 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -173,6 +173,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 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 { * @param fields Fields to get from each Tuple */ SolrEnumerator(TupleStream tupleStream, List>> fields) { - this.tupleStream = tupleStream; try { this.tupleStream.open(); } catch (IOException e) { + IOUtils.closeQuietly(tupleStream); throw new RuntimeException(e); } this.fields = fields;