Buggy code:
public String getLeaderVoteWait ( ) { } private void registerAllCoresAsDown ( final CurrentCoreDescriptorProvider registerOnReconnect , boolean updateLastPublished ) { } private void markAllAsNotLeader ( final CurrentCoreDescriptorProvider registerOnReconnect ) { } public void close ( ) { } public boolean configFileExists ( String collection , String fileName ) throws InterruptedException , KeeperException { } public ClusterState getClusterState ( ) { } public byte [ ] getConfigFileData ( String zkConfigName , String fileName ) throws InterruptedException , KeeperException { } private String getHostAddress ( String host ) throws IOException { } private String getHostNameFromAddress ( String addr ) { } public String getHostName ( ) { } public String getHostPort ( ) { } public SolrZkClient getZkClient ( ) { } public String getZkServerAddress ( ) { } private void init ( CurrentCoreDescriptorProvider registerOnReconnect ) { } public void publishAndWaitForDownStates ( ) throws InterruptedException , KeeperException { } public static boolean checkChrootPath ( String zkHost , boolean create ) throws InterruptedException , KeeperException { } private static boolean containsChroot ( String zkHost ) { } public boolean isConnected ( ) { } private void createEphemeralLiveNode ( ) throws InterruptedException , KeeperException { } public String getNodeName ( ) { } public boolean pathExists ( String path ) throws InterruptedException , KeeperException { } public String readConfigName ( String collection ) throws InterruptedException , KeeperException { } public String register ( String coreName , final CoreDescriptor desc ) throws Exception { } public String register ( String coreName , final CoreDescriptor desc , boolean recoverReloadedCores , boolean afterExpiration ) throws Exception { } private String getLeader ( final CloudDescriptor cloudDesc , int timeoutms ) { } public ZkCoreNodeProps getLeaderProps ( final String collection , final String slice , int timeoutms ) throws InterruptedException { } public ZkCoreNodeProps getLeaderProps ( final String collection , final String slice , int timeoutms , boolean failImmediatelyOnExpiration ) throws InterruptedException { } private void joinElection ( CoreDescriptor cd , boolean afterExpiration ) throws IOException , InterruptedException , KeeperException { } private boolean checkRecovery ( String coreName , final CoreDescriptor desc , boolean recoverReloadedCores , final boolean isLeader , final CloudDescriptor cloudDesc , final String collection , final String shardZkNodeName , String shardId , ZkNodeProps leaderProps , SolrCore core , CoreContainer cc ) { } public String getBaseUrl ( ) { } public void publish ( final CoreDescriptor cd , final String state ) throws InterruptedException , KeeperException { } public void publish ( final CoreDescriptor cd , final String state , boolean updateLastState ) throws InterruptedException , KeeperException { } private boolean needsToBeAssignedShardId ( final CoreDescriptor desc , final ClusterState state , final String coreNodeName ) { } public void unregister ( String coreName , CoreDescriptor cd ) throws InterruptedException , KeeperException { } public void createCollection ( String collection ) throws InterruptedException , KeeperException { } public void uploadToZK ( File dir , String zkPath ) throws IOException , InterruptedException , KeeperException { } public void uploadConfigDir ( File dir , String configName ) throws IOException , InterruptedException , KeeperException { } void printLayoutToStdOut ( ) throws InterruptedException , KeeperException { } public void createCollectionZkNode ( CloudDescriptor cd ) throws InterruptedException , KeeperException { } private void getConfName ( String collection , String collectionPath , Map < String , Object > collectionProps ) throws InterruptedException , KeeperException { } public ZkStateReader getZkStateReader ( ) { } private String doGetShardIdProcess ( String coreName , CoreDescriptor descriptor ) { } public static void uploadToZK ( SolrZkClient zkClient , File dir , String zkPath ) throws IOException , InterruptedException , KeeperException { } public static void downloadFromZK ( SolrZkClient zkClient , String zkPath , File dir ) throws IOException , InterruptedException , KeeperException { List < String > files = zkClient . getChildren ( zkPath , null , true ) ; for ( String file : files ) { List < String > children = zkClient . getChildren ( ( ( zkPath + "//" ) + file ) , null , true ) ; if ( ( children . size ( ) ) == 0 ) { byte [ ] data = zkClient . getData ( ( ( zkPath + "//" ) + file ) , null , null , true ) ; dir . mkdirs ( ) ; ZkController . log . info ( ( "Write<seq2seq4repair_space>file<seq2seq4repair_space>" + ( new File ( dir , file ) ) ) ) ; <START_BUG> FileUtils . writeStringToFile ( new File ( dir , file ) , new String ( data , "UTF-8" ) , "UTF-8" ) ; <END_BUG> } else { ZkController . downloadFromZK ( zkClient , ( ( zkPath + "//" ) + file ) , new File ( dir , file ) ) ; } } } public String getCoreNodeName ( CoreDescriptor descriptor ) { } public static void uploadConfigDir ( SolrZkClient zkClient , File dir , String configName ) throws IOException , InterruptedException , KeeperException { } public static void downloadConfigDir ( SolrZkClient zkClient , String configName , File dir ) throws IOException , InterruptedException , KeeperException { } public void preRegister ( SolrCore core ) throws InterruptedException , KeeperException { } private ZkCoreNodeProps waitForLeaderToSeeDownState ( CoreDescriptor descriptor , final String coreZkNodeName ) { } public static void linkConfSet ( SolrZkClient zkClient , String collection , String confSetName ) throws InterruptedException , KeeperException { } public static void bootstrapConf ( SolrZkClient zkClient , ConfigSolr cfg , String solrHome ) throws IOException , InterruptedException , KeeperException { } public DistributedQueue getOverseerJobQueue ( ) { } public DistributedQueue getOverseerCollectionQueue ( ) { } public int getClientTimeout ( ) { } public UpdateShardHandler getUpdateShardHandler ( ) { } static String generateNodeName ( final String hostName , final String hostPort , final String hostContext ) { } private static String trimLeadingAndTrailingSlashes ( final String in ) { } }

Fix:
FileUtils . writeByteArrayToFile ( new File ( dir , file ) , data ) ;