From eee3b95d888b11d89c14cd0e3340c610da9f0807 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Sun, 17 Oct 2010 23:52:21 +0000 Subject: [PATCH] close request even if exception git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1023599 13f79535-47bb-0310-9956-ffa450edef68 --- .../solr/client/solrj/embedded/EmbeddedSolrServer.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java b/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java index ffeb71fe3df..7df33dfb7b4 100644 --- a/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java +++ b/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java @@ -143,8 +143,9 @@ public class EmbeddedSolrServer extends SolrServer throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "unknown handler: "+path ); } + SolrQueryRequest req = null; try { - SolrQueryRequest req = _parser.buildRequestFrom( core, params, request.getContentStreams() ); + req = _parser.buildRequestFrom( core, params, request.getContentStreams() ); req.getContext().put( "path", path ); SolrQueryResponse rsp = new SolrQueryResponse(); core.execute( handler, req, rsp ); @@ -216,14 +217,10 @@ public class EmbeddedSolrServer extends SolrServer catch (Exception ex) { throw new RuntimeException(ex); } - finally { - req.close(); - } } // Now write it out NamedList normalized = getParsedResponse(req, rsp); - req.close(); return normalized; } catch( IOException iox ) { @@ -233,6 +230,7 @@ public class EmbeddedSolrServer extends SolrServer throw new SolrServerException( ex ); } finally { + if (req != null) req.close(); core.close(); } }