Program: 26551
Project: 26551
Buggy source:
/** 
 * Build up the application state
 * @param cd cluster specification
 * @param siteConf site configuration
 * @param providerRoles roles offered by a provider
 * @param fs filesystem
 * @param historyDir directory containing history files
 * @param liveContainers
 */
public void buildInstance(ClusterDescription cd,Configuration siteConf,List<ProviderRole> providerRoles,FileSystem fs,Path historyDir,List<Container> liveContainers){
  this.siteConf=siteConf;
  setClusterSpec(cd);
  for (  ProviderRole providerRole : providerRoles) {
    buildRole(providerRole);
  }
  buildRoleRequirementsFromClusterSpec();
  ClusterDescription clusterStatus=ClusterDescription.copy(cd);
  Set<String> confKeys=ConfigHelper.sortedConfigKeys(siteConf);
  for (  String key : confKeys) {
    String val=siteConf.get(key);
    clusterStatus.clientProperties.put(key,val);
  }
  startTimeThreshold=1000 * cd.getOptionInt(OptionKeys.CONTAINER_FAILURE_SHORTLIFE,OptionKeys.DEFAULT_CONTAINER_FAILURE_SHORTLIFE);
  failureThreshold=cd.getOptionInt(OptionKeys.CONTAINER_FAILURE_THRESHOLD,OptionKeys.DEFAULT_CONTAINER_FAILURE_THRESHOLD);
  clusterStatus.state=ClusterDescription.STATE_CREATED;
  long now=now();
  clusterStatus.setInfoTime(StatusKeys.INFO_LIVE_TIME_HUMAN,StatusKeys.INFO_LIVE_TIME_MILLIS,now);
  if (0 == clusterStatus.createTime) {
    clusterStatus.createTime=now;
    clusterStatus.setInfoTime(StatusKeys.INFO_CREATE_TIME_HUMAN,StatusKeys.INFO_CREATE_TIME_MILLIS,now);
  }
  clusterStatus.state=ClusterDescription.STATE_LIVE;
  setClusterDescription(clusterStatus);
  roleHistory=new RoleHistory(providerRoles);
  roleHistory.onStart(fs,historyDir);
  rebuildModelFromRestart(liveContainers);
}

Fixed version (ground truth):
/** 
 * Build up the application state
 * @param cd cluster specification
 * @param siteConf site configuration
 * @param providerRoles roles offered by a provider
 * @param fs filesystem
 * @param historyDir directory containing history files
 * @param liveContainers
 */
public void buildInstance(ClusterDescription cd,Configuration siteConf,List<ProviderRole> providerRoles,FileSystem fs,Path historyDir,List<Container> liveContainers) throws BadClusterStateException {
  this.siteConf=siteConf;
  setClusterSpec(cd);
  for (  ProviderRole providerRole : providerRoles) {
    buildRole(providerRole);
  }
  buildRoleRequirementsFromClusterSpec();
  ClusterDescription clusterStatus=ClusterDescription.copy(cd);
  Set<String> confKeys=ConfigHelper.sortedConfigKeys(siteConf);
  for (  String key : confKeys) {
    String val=siteConf.get(key);
    clusterStatus.clientProperties.put(key,val);
  }
  startTimeThreshold=1000 * cd.getOptionInt(OptionKeys.CONTAINER_FAILURE_SHORTLIFE,OptionKeys.DEFAULT_CONTAINER_FAILURE_SHORTLIFE);
  failureThreshold=cd.getOptionInt(OptionKeys.CONTAINER_FAILURE_THRESHOLD,OptionKeys.DEFAULT_CONTAINER_FAILURE_THRESHOLD);
  clusterStatus.state=ClusterDescription.STATE_CREATED;
  long now=now();
  clusterStatus.setInfoTime(StatusKeys.INFO_LIVE_TIME_HUMAN,StatusKeys.INFO_LIVE_TIME_MILLIS,now);
  if (0 == clusterStatus.createTime) {
    clusterStatus.createTime=now;
    clusterStatus.setInfoTime(StatusKeys.INFO_CREATE_TIME_HUMAN,StatusKeys.INFO_CREATE_TIME_MILLIS,now);
  }
  clusterStatus.state=ClusterDescription.STATE_LIVE;
  setClusterDescription(clusterStatus);
  roleHistory=new RoleHistory(providerRoles);
  roleHistory.onStart(fs,historyDir);
  rebuildModelFromRestart(liveContainers);
}