SOLR-4266: HttpSolrServer does not release connection properly on exception when no response parser is used.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1434109 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2013-01-16 18:56:47 +00:00
parent 8a23ab7cfd
commit d776712255
2 changed files with 7 additions and 1 deletions
solr
CHANGES.txt
solrj/src/java/org/apache/solr/client/solrj/impl

View File

@ -562,6 +562,9 @@ Bug Fixes
* SOLR-4303: On replication, if the generation of the master is lower than the
slave we need to force a full copy of the index. (Mark Miller, Gregg Donovan)
* SOLR-4266: HttpSolrServer does not release connection properly on exception
when no response parser is used. (Steve Molloy via Mark Miller)
Other Changes
----------------------

View File

@ -346,6 +346,7 @@ public class HttpSolrServer extends SolrServer {
method.addHeader("User-Agent", AGENT);
InputStream respBody = null;
boolean shouldClose = true;
try {
// Execute the method.
@ -378,6 +379,8 @@ public class HttpSolrServer extends SolrServer {
// no processor specified, return raw stream
NamedList<Object> rsp = new NamedList<Object>();
rsp.add("stream", respBody);
// Only case where stream should not be closed
shouldClose = false;
return rsp;
}
String charset = EntityUtils.getContentCharSet(response.getEntity());
@ -413,7 +416,7 @@ public class HttpSolrServer extends SolrServer {
throw new SolrServerException(
"IOException occured when talking to server at: " + getBaseURL(), e);
} finally {
if (respBody != null && processor!=null) {
if (respBody != null && shouldClose) {
try {
respBody.close();
} catch (Throwable t) {} // ignore