close request in DirectSolrConnection

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@632541 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2008-03-01 02:53:09 +00:00
parent dd622ea5f5
commit 0148a9cee6
1 changed files with 18 additions and 11 deletions

View File

@ -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();
}
/**