Program: 82232
Project: 82232
Buggy source:
public static ThriftServer createServer(int serverIndex,BlurConfiguration configuration) throws Exception {
  Thread.setDefaultUncaughtExceptionHandler(new SimpleUncaughtExceptionHandler());
  String bindAddress=configuration.get(BLUR_CONTROLLER_BIND_ADDRESS);
  int configBindPort=configuration.getInt(BLUR_CONTROLLER_BIND_PORT,-1);
  int instanceBindPort=configBindPort + serverIndex;
  if (configBindPort == 0) {
    instanceBindPort=0;
  }
  TNonblockingServerSocket tNonblockingServerSocket=ThriftServer.getTNonblockingServerSocket(bindAddress,instanceBindPort);
  if (configBindPort == 0) {
    instanceBindPort=tNonblockingServerSocket.getServerSocket().getLocalPort();
  }
  LOG.info("String_Node_Str",serverIndex,bindAddress + "String_Node_Str" + instanceBindPort);
  String nodeName=getNodeName(configuration,BLUR_CONTROLLER_HOSTNAME);
  nodeName=nodeName + "String_Node_Str" + instanceBindPort;
  String zkConnectionStr=isEmpty(configuration.get(BLUR_ZOOKEEPER_CONNECTION),BLUR_ZOOKEEPER_CONNECTION);
  BlurQueryChecker queryChecker=new BlurQueryChecker(configuration);
  int sessionTimeout=configuration.getInt(BLUR_ZOOKEEPER_TIMEOUT,BLUR_ZOOKEEPER_TIMEOUT_DEFAULT);
  final ZooKeeper zooKeeper=ZkUtils.newZooKeeper(zkConnectionStr,sessionTimeout);
  BlurUtil.setupZookeeper(zooKeeper,null);
  final ZookeeperClusterStatus clusterStatus=new ZookeeperClusterStatus(zooKeeper,configuration);
  int timeout=configuration.getInt(BLUR_CONTROLLER_SHARD_CONNECTION_TIMEOUT,60000);
  BlurControllerServer.BlurClient client=new BlurControllerServer.BlurClientRemote(timeout);
  String tmpPath=configuration.get(BLUR_TMP_PATH,getDefaultTmpPath(BLUR_TMP_PATH));
  int numberOfControllerWorkerCommandThreads=configuration.getInt(BLUR_CONTROLLER_COMMAND_WORKER_THREADS,16);
  int numberOfControllerDriverCommandThreads=configuration.getInt(BLUR_CONTROLLER_COMMAND_DRIVER_THREADS,16);
  String commandPath=configuration.get(BLUR_COMMAND_LIB_PATH,getCommandLibPath());
  Configuration config=new Configuration();
  final ControllerCommandManager controllerCommandManager=new ControllerCommandManager(tmpPath,commandPath,numberOfControllerWorkerCommandThreads,numberOfControllerDriverCommandThreads,Connection.DEFAULT_TIMEOUT,config);
  final BlurControllerServer controllerServer=new BlurControllerServer();
  controllerServer.setClient(client);
  controllerServer.setCommandManager(controllerCommandManager);
  controllerServer.setClusterStatus(clusterStatus);
  controllerServer.setZookeeper(zooKeeper);
  controllerServer.setNodeName(nodeName);
  controllerServer.setRemoteFetchCount(configuration.getInt(BLUR_CONTROLLER_REMOTE_FETCH_COUNT,100));
  controllerServer.setQueryChecker(queryChecker);
  controllerServer.setThreadCount(configuration.getInt(BLUR_CONTROLLER_SERVER_REMOTE_THREAD_COUNT,64));
  controllerServer.setMaxFetchRetries(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_FETCH_RETRIES,3));
  controllerServer.setMaxMutateRetries(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_MUTATE_RETRIES,3));
  controllerServer.setMaxDefaultRetries(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_DEFAULT_RETRIES,3));
  controllerServer.setFetchDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_FETCH_DELAY,500));
  controllerServer.setMutateDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_MUTATE_DELAY,500));
  controllerServer.setDefaultDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_DEFAULT_DELAY,500));
  controllerServer.setMaxFetchDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_FETCH_DELAY,2000));
  controllerServer.setMaxMutateDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_MUTATE_DELAY,2000));
  controllerServer.setMaxDefaultDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_DEFAULT_DELAY,2000));
  controllerServer.setMaxRecordsPerRowFetchRequest(configuration.getInt(BLUR_MAX_RECORDS_PER_ROW_FETCH_REQUEST,1000));
  controllerServer.setConfiguration(configuration);
  controllerServer.init();
  final TraceStorage traceStorage=setupTraceStorage(configuration);
  Trace.setStorage(traceStorage);
  Trace.setNodeName(nodeName);
  Iface iface=BlurUtil.wrapFilteredBlurServer(configuration,controllerServer,false);
  iface=BlurUtil.recordMethodCallsAndAverageTimes(iface,Iface.class,true);
  iface=BlurUtil.runWithUser(iface,true);
  iface=BlurUtil.runTrace(iface,true);
  iface=BlurUtil.lastChanceErrorHandling(iface,Iface.class);
  int threadCount=configuration.getInt(BLUR_CONTROLLER_SERVER_THRIFT_THREAD_COUNT,32);
  ControllerServerEventHandler eventHandler=new ControllerServerEventHandler();
  final ThriftBlurControllerServer server=new ThriftBlurControllerServer();
  server.setNodeName(nodeName);
  server.setServerTransport(tNonblockingServerSocket);
  server.setThreadCount(threadCount);
  server.setEventHandler(eventHandler);
  server.setIface(iface);
  server.setAcceptQueueSizePerThread(configuration.getInt(BLUR_CONTROLLER_THRIFT_ACCEPT_QUEUE_SIZE_PER_THREAD,4));
  server.setMaxReadBufferBytes(configuration.getLong(BLUR_CONTROLLER_THRIFT_MAX_READ_BUFFER_BYTES,Long.MAX_VALUE));
  server.setSelectorThreads(configuration.getInt(BLUR_CONTROLLER_THRIFT_SELECTOR_THREADS,2));
  server.setMaxFrameSize(configuration.getInt(BLUR_THRIFT_MAX_FRAME_SIZE,BLUR_THRIFT_DEFAULT_MAX_FRAME_SIZE));
  int configGuiPort=Integer.parseInt(configuration.get(BLUR_GUI_CONTROLLER_PORT));
  int instanceGuiPort=configGuiPort + serverIndex;
  if (configGuiPort == 0) {
    instanceGuiPort=0;
  }
  final HttpJettyServer httpServer;
  if (configGuiPort >= 0) {
    httpServer=new HttpJettyServer(HttpJettyServer.class,instanceGuiPort);
    int port=httpServer.getLocalPort();
    configuration.setInt(BLUR_HTTP_STATUS_RUNNING_PORT,port);
  }
 else {
    httpServer=null;
  }
  if (httpServer != null) {
    WebAppContext context=httpServer.getContext();
    context.addServlet(new ServletHolder(new TServlet(new Blur.Processor<Blur.Iface>(iface),new TJSONProtocol.Factory())),"String_Node_Str");
    context.addServlet(new ServletHolder(new JSONReporterServlet()),"String_Node_Str");
  }
  BlurShutdown shutdown=new BlurShutdown(){
    @Override public void shutdown(){
      ThreadWatcher threadWatcher=ThreadWatcher.instance();
      quietClose(controllerCommandManager,traceStorage,server,controllerServer,clusterStatus,zooKeeper,threadWatcher,httpServer);
    }
  }
;
  server.setShutdown(shutdown);
  new BlurServerShutDown().register(shutdown,zooKeeper);
  return server;
}

Fixed version (ground truth):
public static ThriftServer createServer(int serverIndex,BlurConfiguration configuration) throws Exception {
  Thread.setDefaultUncaughtExceptionHandler(new SimpleUncaughtExceptionHandler());
  String bindAddress=configuration.get(BLUR_CONTROLLER_BIND_ADDRESS);
  int configBindPort=configuration.getInt(BLUR_CONTROLLER_BIND_PORT,-1);
  int instanceBindPort=configBindPort + serverIndex;
  if (configBindPort == 0) {
    instanceBindPort=0;
  }
  TNonblockingServerSocket tNonblockingServerSocket=ThriftServer.getTNonblockingServerSocket(bindAddress,instanceBindPort);
  if (configBindPort == 0) {
    instanceBindPort=tNonblockingServerSocket.getServerSocket().getLocalPort();
  }
  LOG.info("String_Node_Str",serverIndex,bindAddress + "String_Node_Str" + instanceBindPort);
  String nodeName=getNodeName(configuration,BLUR_CONTROLLER_HOSTNAME);
  nodeName=nodeName + "String_Node_Str" + instanceBindPort;
  String zkConnectionStr=isEmpty(configuration.get(BLUR_ZOOKEEPER_CONNECTION),BLUR_ZOOKEEPER_CONNECTION);
  BlurQueryChecker queryChecker=new BlurQueryChecker(configuration);
  int sessionTimeout=configuration.getInt(BLUR_ZOOKEEPER_TIMEOUT,BLUR_ZOOKEEPER_TIMEOUT_DEFAULT);
  final ZooKeeper zooKeeper=ZkUtils.newZooKeeper(zkConnectionStr,sessionTimeout);
  BlurUtil.setupZookeeper(zooKeeper,null);
  final ZookeeperClusterStatus clusterStatus=new ZookeeperClusterStatus(zooKeeper,configuration);
  int timeout=configuration.getInt(BLUR_CONTROLLER_SHARD_CONNECTION_TIMEOUT,60000);
  BlurControllerServer.BlurClient client=new BlurControllerServer.BlurClientRemote(timeout);
  File defaultTmpPath=getDefaultTmpPath(BLUR_TMP_PATH);
  String configTmpPath=configuration.get(BLUR_TMP_PATH);
  File tmpPath;
  if (!(configTmpPath == null || configTmpPath.isEmpty())) {
    tmpPath=new File(configTmpPath);
  }
 else {
    tmpPath=defaultTmpPath;
  }
  int numberOfControllerWorkerCommandThreads=configuration.getInt(BLUR_CONTROLLER_COMMAND_WORKER_THREADS,16);
  int numberOfControllerDriverCommandThreads=configuration.getInt(BLUR_CONTROLLER_COMMAND_DRIVER_THREADS,16);
  String commandPath=configuration.get(BLUR_COMMAND_LIB_PATH,getCommandLibPath());
  Configuration config=new Configuration();
  final ControllerCommandManager controllerCommandManager=new ControllerCommandManager(tmpPath,commandPath,numberOfControllerWorkerCommandThreads,numberOfControllerDriverCommandThreads,Connection.DEFAULT_TIMEOUT,config);
  final BlurControllerServer controllerServer=new BlurControllerServer();
  controllerServer.setClient(client);
  controllerServer.setCommandManager(controllerCommandManager);
  controllerServer.setClusterStatus(clusterStatus);
  controllerServer.setZookeeper(zooKeeper);
  controllerServer.setNodeName(nodeName);
  controllerServer.setRemoteFetchCount(configuration.getInt(BLUR_CONTROLLER_REMOTE_FETCH_COUNT,100));
  controllerServer.setQueryChecker(queryChecker);
  controllerServer.setThreadCount(configuration.getInt(BLUR_CONTROLLER_SERVER_REMOTE_THREAD_COUNT,64));
  controllerServer.setMaxFetchRetries(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_FETCH_RETRIES,3));
  controllerServer.setMaxMutateRetries(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_MUTATE_RETRIES,3));
  controllerServer.setMaxDefaultRetries(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_DEFAULT_RETRIES,3));
  controllerServer.setFetchDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_FETCH_DELAY,500));
  controllerServer.setMutateDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_MUTATE_DELAY,500));
  controllerServer.setDefaultDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_DEFAULT_DELAY,500));
  controllerServer.setMaxFetchDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_FETCH_DELAY,2000));
  controllerServer.setMaxMutateDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_MUTATE_DELAY,2000));
  controllerServer.setMaxDefaultDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_DEFAULT_DELAY,2000));
  controllerServer.setMaxRecordsPerRowFetchRequest(configuration.getInt(BLUR_MAX_RECORDS_PER_ROW_FETCH_REQUEST,1000));
  controllerServer.setConfiguration(configuration);
  controllerServer.init();
  final TraceStorage traceStorage=setupTraceStorage(configuration);
  Trace.setStorage(traceStorage);
  Trace.setNodeName(nodeName);
  Iface iface=BlurUtil.wrapFilteredBlurServer(configuration,controllerServer,false);
  iface=BlurUtil.recordMethodCallsAndAverageTimes(iface,Iface.class,true);
  iface=BlurUtil.runWithUser(iface,true);
  iface=BlurUtil.runTrace(iface,true);
  iface=BlurUtil.lastChanceErrorHandling(iface,Iface.class);
  int threadCount=configuration.getInt(BLUR_CONTROLLER_SERVER_THRIFT_THREAD_COUNT,32);
  ControllerServerEventHandler eventHandler=new ControllerServerEventHandler();
  final ThriftBlurControllerServer server=new ThriftBlurControllerServer();
  server.setNodeName(nodeName);
  server.setServerTransport(tNonblockingServerSocket);
  server.setThreadCount(threadCount);
  server.setEventHandler(eventHandler);
  server.setIface(iface);
  server.setAcceptQueueSizePerThread(configuration.getInt(BLUR_CONTROLLER_THRIFT_ACCEPT_QUEUE_SIZE_PER_THREAD,4));
  server.setMaxReadBufferBytes(configuration.getLong(BLUR_CONTROLLER_THRIFT_MAX_READ_BUFFER_BYTES,Long.MAX_VALUE));
  server.setSelectorThreads(configuration.getInt(BLUR_CONTROLLER_THRIFT_SELECTOR_THREADS,2));
  server.setMaxFrameSize(configuration.getInt(BLUR_THRIFT_MAX_FRAME_SIZE,BLUR_THRIFT_DEFAULT_MAX_FRAME_SIZE));
  int configGuiPort=Integer.parseInt(configuration.get(BLUR_GUI_CONTROLLER_PORT));
  int instanceGuiPort=configGuiPort + serverIndex;
  if (configGuiPort == 0) {
    instanceGuiPort=0;
  }
  final HttpJettyServer httpServer;
  if (configGuiPort >= 0) {
    httpServer=new HttpJettyServer(HttpJettyServer.class,instanceGuiPort);
    int port=httpServer.getLocalPort();
    configuration.setInt(BLUR_HTTP_STATUS_RUNNING_PORT,port);
  }
 else {
    httpServer=null;
  }
  if (httpServer != null) {
    WebAppContext context=httpServer.getContext();
    context.addServlet(new ServletHolder(new TServlet(new Blur.Processor<Blur.Iface>(iface),new TJSONProtocol.Factory())),"String_Node_Str");
    context.addServlet(new ServletHolder(new JSONReporterServlet()),"String_Node_Str");
  }
  BlurShutdown shutdown=new BlurShutdown(){
    @Override public void shutdown(){
      ThreadWatcher threadWatcher=ThreadWatcher.instance();
      quietClose(controllerCommandManager,traceStorage,server,controllerServer,clusterStatus,zooKeeper,threadWatcher,httpServer);
    }
  }
;
  server.setShutdown(shutdown);
  new BlurServerShutDown().register(shutdown,zooKeeper);
  return server;
}