diff --git a/CHANGES.txt b/CHANGES.txt index a517b0aae9a..7b185ddbfe9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -162,6 +162,9 @@ Bug Fixes * SOLR-1667: PatternTokenizer does not reset attributes such as positionIncrementGap (Robert Muir via shalin) +* SOLR-1711: SolrJ - StreamingUpdateSolrServer had a race condition that + could halt the streaming of documents. (Attila Babo via yonik) + Other Changes ---------------------- diff --git a/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java b/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java index b328c861848..8254b93dacf 100644 --- a/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java +++ b/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java @@ -99,6 +99,7 @@ public class StreamingUpdateSolrServer extends CommonsHttpSolrServer log.info( "starting runner: {}" , this ); PostMethod method = null; try { + do { RequestEntity request = new RequestEntity() { // we don't know the length public long getContentLength() { return -1; } @@ -159,6 +160,7 @@ public class StreamingUpdateSolrServer extends CommonsHttpSolrServer msg.append( "request: "+method.getURI() ); handleError( new Exception( msg.toString() ) ); } + } while( ! queue.isEmpty()); } catch (Throwable e) { handleError( e ); @@ -166,6 +168,7 @@ public class StreamingUpdateSolrServer extends CommonsHttpSolrServer finally { try { // make sure to release the connection + if(method != null) method.releaseConnection(); } catch( Exception ex ){} @@ -212,11 +215,11 @@ public class StreamingUpdateSolrServer extends CommonsHttpSolrServer queue.put( req ); + synchronized( runners ) { if( runners.isEmpty() || (queue.remainingCapacity() < queue.size() && runners.size() < threadCount) ) { - synchronized( runners ) { Runner r = new Runner(); scheduler.execute( r ); runners.add( r );