diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 8b85c313611..f246c1691f6 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -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 ---------------------- diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java index 8ed828742a8..3806cfce323 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java @@ -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 rsp = new NamedList(); 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