You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2013/10/12 23:26:54 UTC

svn commit: r1531596 - in /lucene/dev/trunk/solr: CHANGES.txt solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java

Author: markrmiller
Date: Sat Oct 12 21:26:54 2013
New Revision: 1531596

URL: http://svn.apache.org/r1531596
Log:
SOLR-4327: HttpSolrServer can leak connections on errors.

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1531596&r1=1531595&r2=1531596&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Sat Oct 12 21:26:54 2013
@@ -182,6 +182,8 @@ Bug Fixes
 * SOLR-5325: ZooKeeper connection loss can cause the Overseer to stop processing
   commands. (Christine Poerschke, Mark Miller, Jessica Cheng)
 
+* SOLR-4327: HttpSolrServer can leak connections on errors. (Karl Wright, Mark Miller)
+
 Other Changes
 ----------------------
 

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java?rev=1531596&r1=1531595&r2=1531596&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java Sat Oct 12 21:26:54 2013
@@ -360,7 +360,7 @@ public class HttpSolrServer extends Solr
     
     InputStream respBody = null;
     boolean shouldClose = true;
-    
+    boolean success = false;
     try {
       // Execute the method.
       final HttpResponse response = httpClient.execute(method);
@@ -404,6 +404,7 @@ public class HttpSolrServer extends Solr
         rsp.add("stream", respBody);
         // Only case where stream should not be closed
         shouldClose = false;
+        success = true;
         return rsp;
       }
       
@@ -462,6 +463,7 @@ public class HttpSolrServer extends Solr
         }
         throw new RemoteSolrException(httpStatus, reason, null);
       }
+      success = true;
       return rsp;
     } catch (ConnectException e) {
       throw new SolrServerException("Server refused connection at: "
@@ -478,6 +480,9 @@ public class HttpSolrServer extends Solr
         try {
           respBody.close();
         } catch (Throwable t) {} // ignore
+        if (!success) {
+          method.abort();
+        }
       }
     }
   }