Buggy code:
public class TestReplicationHandler extends SolrTestCaseJ4 { private static final String CONF_DIR = ( ( ( ( "." + ( File . separator ) ) + "solr" ) + ( File . separator ) ) + "conf" ) + ( File . separator ) ; static JettySolrRunner masterJetty ; static JettySolrRunner slaveJetty ; static SolrServer masterClient ; static SolrServer slaveClient ; static TestReplicationHandler . SolrInstance master = null ; static TestReplicationHandler . SolrInstance slave = null ; static String context = "//solr" ; static int nDocs = 500 ; @ BeforeClass public static void beforeClass ( ) throws Exception { } public void clearIndexWithReplication ( ) throws Exception { } @ AfterClass public static void afterClass ( ) throws Exception { } private static JettySolrRunner createJetty ( TestReplicationHandler . SolrInstance instance ) throws Exception { } private static SolrServer createNewSolrServer ( int port ) { } int index ( SolrServer s , Object ... fields ) throws Exception { } NamedList query ( String query , SolrServer s ) throws SolrServerException { } private NamedList rQuery ( int expectedDocCount , String query , SolrServer server ) throws Exception { } private NamedList < Object > getDetails ( SolrServer s ) throws Exception { } @ Test public void testDetails ( ) throws Exception { } @ Test public void testReplicateAfterWrite2Slave ( ) throws Exception { } @ Test public void testIndexAndConfigReplication ( ) throws Exception { } @ Test public void testStopPoll ( ) throws Exception { } @ Test public void testSnapPullWithMasterUrl ( ) throws Exception { } @ Test public void testReplicateAfterStartup ( ) throws Exception { } @ Test public void testIndexAndConfigAliasReplication ( ) throws Exception { } @ Test public void testBackup ( ) throws Exception { TestReplicationHandler . masterJetty . stop ( ) ; TestReplicationHandler . master . copyConfigFile ( ( ( TestReplicationHandler . CONF_DIR ) + "solrconfig-master1.xml" ) , "solrconfig.xml" ) ; TestReplicationHandler . masterJetty = TestReplicationHandler . createJetty ( TestReplicationHandler . master ) ; TestReplicationHandler . masterClient = TestReplicationHandler . createNewSolrServer ( TestReplicationHandler . masterJetty . getLocalPort ( ) ) ; ( TestReplicationHandler . nDocs ) -- ; TestReplicationHandler . masterClient . deleteByQuery ( "*:*" ) ; for ( int i = 0 ; i < ( TestReplicationHandler . nDocs ) ; i ++ ) index ( TestReplicationHandler . masterClient , "id" , i , "name" , ( "name<seq2seq4repair_space>=<seq2seq4repair_space>" + i ) ) ; TestReplicationHandler . masterClient . commit ( ) ; class BackupThread extends Thread { volatile String fail = null ; @ Override public void run ( ) { String masterUrl = ( ( "http:////localhost:" + ( TestReplicationHandler . masterJetty . getLocalPort ( ) ) ) + "//solr//replication?command=" ) + ( ReplicationHandler . CMD_BACKUP ) ; URL url ; InputStream stream = null ; try { url = new URL ( masterUrl ) ; stream = url . openStream ( ) ; stream . close ( ) ; } catch ( Exception e ) { fail = e . getMessage ( ) ; } finally { IOUtils . closeQuietly ( stream ) ; } } } BackupThread backupThread = new BackupThread ( ) ; backupThread . start ( ) ; File dataDir = new File ( TestReplicationHandler . master . getDataDir ( ) ) ; class CheckStatus extends Thread { volatile String fail = null ; volatile String response = null ; volatile boolean success = false ; @ Override public void run ( ) { String masterUrl = ( ( "http:////localhost:" + ( TestReplicationHandler . masterJetty . getLocalPort ( ) ) ) + "//solr//replication?command=" ) + ( ReplicationHandler . CMD_DETAILS ) ; URL url ; InputStream stream = null ; try { url = new URL ( masterUrl ) ; stream = url . openStream ( ) ; <START_BUG> response = IOUtils . toString ( stream ) ; <END_BUG> if ( response . contains ( "<str<seq2seq4repair_space>name=\"status\">success<//str>" ) ) { success = true ; } stream . close ( ) ; } catch ( Exception e ) { fail = e . getMessage ( ) ; } finally { IOUtils . closeQuietly ( stream ) ; } } } int waitCnt = 0 ; CheckStatus checkStatus = new CheckStatus ( ) ; while ( true ) { checkStatus . run ( ) ; if ( ( checkStatus . fail ) != null ) { fail ( checkStatus . fail ) ; } if ( checkStatus . success ) { break ; } Thread . sleep ( 200 ) ; if ( waitCnt == 10 ) { fail ( ( "Backup<seq2seq4repair_space>success<seq2seq4repair_space>not<seq2seq4repair_space>detected:" + ( checkStatus . response ) ) ) ; } waitCnt ++ ; } if ( ( backupThread . fail ) != null ) { fail ( backupThread . fail ) ; } File [ ] files = dataDir . listFiles ( new FilenameFilter ( ) { public boolean accept ( File dir , String name ) { if ( name . startsWith ( "snapshot" ) ) { return true ; } return false ; } } ) ; assertEquals ( 1 , files . length ) ; File snapDir = files [ 0 ] ; Directory dir = new SimpleFSDirectory ( snapDir . getAbsoluteFile ( ) ) ; IndexSearcher searcher = new IndexSearcher ( dir , true ) ; TopDocs hits = searcher . search ( new MatchAllDocsQuery ( ) , 1 ) ; assertEquals ( TestReplicationHandler . nDocs , hits . totalHits ) ; searcher . close ( ) ; dir . close ( ) ; } private static void copyFile ( File src , File dst ) throws IOException { } private static void copyFile ( File src , File dst , Integer port ) throws IOException { } private static class SolrInstance { private String name ; private Integer testPort ; private File homeDir ; private File confDir ; private File dataDir ; public SolrInstance ( String name , Integer testPort ) { } public String getHomeDir ( ) { } public String getSchemaFile ( ) { }

Fix:
response = IOUtils . toString ( stream , "UTF-8" ) ;