From 0148a9cee64f83b55308175cb63551d4c0851b21 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Sat, 1 Mar 2008 02:53:09 +0000 Subject: [PATCH] close request in DirectSolrConnection git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@632541 13f79535-47bb-0310-9956-ffa450edef68 --- .../solr/servlet/DirectSolrConnection.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java b/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java index 95653af7e64..05a6010ed2f 100644 --- a/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java +++ b/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java @@ -157,18 +157,25 @@ public class DirectSolrConnection streams.add( new ContentStreamBase.StringStream( body ) ); } - SolrQueryRequest req = parser.buildRequestFrom( core, params, streams ); - SolrQueryResponse rsp = new SolrQueryResponse(); - core.execute( handler, req, rsp ); - if( rsp.getException() != null ) { - throw rsp.getException(); + SolrQueryRequest req = null; + try { + req = parser.buildRequestFrom( core, params, streams ); + SolrQueryResponse rsp = new SolrQueryResponse(); + core.execute( handler, req, rsp ); + if( rsp.getException() != null ) { + throw rsp.getException(); + } + + // Now write it out + QueryResponseWriter responseWriter = core.getQueryResponseWriter(req); + StringWriter out = new StringWriter(); + responseWriter.write(out, req, rsp); + return out.toString(); + } finally { + if (req != null) { + req.close(); + } } - - // Now write it out - QueryResponseWriter responseWriter = core.getQueryResponseWriter(req); - StringWriter out = new StringWriter(); - responseWriter.write(out, req, rsp); - return out.toString(); } /**