Buggy code:
public class StreamingUpdateSolrServer extends CommonsHttpSolrServer { static final Logger log = LoggerFactory . getLogger ( StreamingUpdateSolrServer . class ) ; final BlockingQueue < UpdateRequest > queue ; final ExecutorService scheduler = Executors . newCachedThreadPool ( ) ; final String updateUrl = "//update" ; final Queue < StreamingUpdateSolrServer . Runner > runners ; volatile CountDownLatch lock = null ; final int threadCount ; public StreamingUpdateSolrServer ( String solrServerUrl , int queueSize , int threadCount ) throws MalformedURLException { } class Runner implements Runnable { final Lock runnerLock = new ReentrantLock ( ) ; public void run ( ) { runnerLock . lock ( ) ; StreamingUpdateSolrServer . log . info ( "starting<seq2seq4repair_space>runner:<seq2seq4repair_space>{}" , this ) ; PostMethod method = null ; try { RequestEntity request = new RequestEntity ( ) { public long getContentLength ( ) { return - 1 ; } public String getContentType ( ) { return ClientUtils . TEXT_XML ; } public boolean isRepeatable ( ) { return false ; } public void writeRequest ( OutputStream out ) throws IOException { try { <START_BUG> OutputStreamWriter writer = new OutputStreamWriter ( out ) ; <END_BUG> writer . append ( "<stream>" ) ; UpdateRequest req = queue . poll ( 250 , TimeUnit . MILLISECONDS ) ; while ( req != null ) { StreamingUpdateSolrServer . log . debug ( "sending:<seq2seq4repair_space>{}" , req ) ; req . writeXML ( writer ) ; SolrParams params = req . getParams ( ) ; if ( params != null ) { String fmt = null ; if ( params . getBool ( OPTIMIZE , false ) ) { fmt = "<optimize<seq2seq4repair_space>waitSearcher=\"%s\"<seq2seq4repair_space>waitFlush=\"%s\"<seq2seq4repair_space>//>" ; } else if ( params . getBool ( COMMIT , false ) ) { fmt = "<commit<seq2seq4repair_space>waitSearcher=\"%s\"<seq2seq4repair_space>waitFlush=\"%s\"<seq2seq4repair_space>//>" ; } if ( fmt != null ) { StreamingUpdateSolrServer . log . info ( fmt ) ; writer . write ( String . format ( fmt , ( ( params . getBool ( WAIT_SEARCHER , false ) ) + "" ) , ( ( params . getBool ( WAIT_FLUSH , false ) ) + "" ) ) ) ; } } writer . flush ( ) ; req = queue . poll ( 250 , TimeUnit . MILLISECONDS ) ; } writer . append ( "<//stream>" ) ; writer . flush ( ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } } } ; method = new PostMethod ( ( ( _baseURL ) + ( updateUrl ) ) ) ; method . setRequestEntity ( request ) ; method . setFollowRedirects ( false ) ; method . addRequestHeader ( "User-Agent" , AGENT ) ; int statusCode = getHttpClient ( ) . executeMethod ( method ) ; if ( statusCode != ( HttpStatus . SC_OK ) ) { StringBuilder msg = new StringBuilder ( ) ; msg . append ( method . getStatusLine ( ) . getReasonPhrase ( ) ) ; msg . append ( "\n\n" ) ; msg . append ( method . getStatusText ( ) ) ; msg . append ( "\n\n" ) ; msg . append ( ( "request:<seq2seq4repair_space>" + ( method . getURI ( ) ) ) ) ; handleError ( new Exception ( msg . toString ( ) ) ) ; } } catch ( Throwable e ) { handleError ( e ) ; } finally { try { method . releaseConnection ( ) ; } catch ( Exception ex ) { } synchronized ( runners ) { runners . remove ( this ) ; } StreamingUpdateSolrServer . log . info ( "finished:<seq2seq4repair_space>{}" , this ) ; runnerLock . unlock ( ) ; } } } @ Override public NamedList < Object > request ( final SolrRequest request ) throws IOException , SolrServerException { } public synchronized void blockUntilFinished ( ) { } public void handleError ( Throwable ex ) { } }

Fix:
OutputStreamWriter writer = new OutputStreamWriter ( out , "UTF-8" ) ;