close request even if exception

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1023599 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2010-10-17 23:52:21 +00:00
parent 3944a8f84b
commit eee3b95d88
1 changed files with 3 additions and 5 deletions

View File

@ -143,8 +143,9 @@ public class EmbeddedSolrServer extends SolrServer
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "unknown handler: "+path ); throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "unknown handler: "+path );
} }
SolrQueryRequest req = null;
try { try {
SolrQueryRequest req = _parser.buildRequestFrom( core, params, request.getContentStreams() ); req = _parser.buildRequestFrom( core, params, request.getContentStreams() );
req.getContext().put( "path", path ); req.getContext().put( "path", path );
SolrQueryResponse rsp = new SolrQueryResponse(); SolrQueryResponse rsp = new SolrQueryResponse();
core.execute( handler, req, rsp ); core.execute( handler, req, rsp );
@ -216,14 +217,10 @@ public class EmbeddedSolrServer extends SolrServer
catch (Exception ex) { catch (Exception ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
finally {
req.close();
}
} }
// Now write it out // Now write it out
NamedList<Object> normalized = getParsedResponse(req, rsp); NamedList<Object> normalized = getParsedResponse(req, rsp);
req.close();
return normalized; return normalized;
} }
catch( IOException iox ) { catch( IOException iox ) {
@ -233,6 +230,7 @@ public class EmbeddedSolrServer extends SolrServer
throw new SolrServerException( ex ); throw new SolrServerException( ex );
} }
finally { finally {
if (req != null) req.close();
core.close(); core.close();
} }
} }