Program: 116646
Project: 116646
Buggy source:
@Override public void unregisterService(String clusterId) throws UnregisteredClusterException {
  final String clusterId_=clusterId;
  Runnable r=new Runnable(){
    public void run(){
      ClusterContext ctxt=dataHolder.getClusterContext(clusterId_);
      if (ctxt == null) {
        String msg="String_Node_Str" + clusterId_;
        log.error(msg);
      }
      Collection<Member> members=TopologyManager.getTopology().getService(ctxt.getCartridgeType()).getCluster(clusterId_).getMembers();
      long endTime=System.currentTimeMillis() + ctxt.getTimeoutInMillis() * members.size();
      while (members.size() > 0 && System.currentTimeMillis() < endTime) {
        CloudControllerUtil.sleep(1000);
      }
      if (members.size() > 0) {
        for (        Member member : members) {
          try {
            terminateInstance(member.getMemberId());
          }
 catch (          Exception e) {
            log.warn("String_Node_Str" + member.getMemberId(),e);
          }
        }
      }
      log.info("String_Node_Str" + clusterId_);
      deleteVolumes(ctxt);
      TopologyBuilder.handleClusterRemoved(ctxt);
      dataHolder.removeClusterContext(clusterId_);
      dataHolder.removeMemberContextsOfCluster(clusterId_);
      persist();
    }
    private void deleteVolumes(    ClusterContext ctxt){
      if (ctxt.isVolumeRequired()) {
        Cartridge cartridge=dataHolder.getCartridge(ctxt.getCartridgeType());
        if (cartridge != null && cartridge.getIaases() != null && !ctxt.getListOfVolumes().isEmpty()) {
          for (          Volume volume : ctxt.getListOfVolumes()) {
            if (volume.getId() != null) {
              String iaasType=volume.getIaasType();
              Iaas iaas=dataHolder.getIaasProvider(iaasType).getIaas();
              if (iaas != null) {
                try {
                  iaas.deleteVolume(volume.getId());
                }
 catch (                Exception ignore) {
                  if (log.isDebugEnabled()) {
                    log.debug(ignore);
                  }
                }
              }
            }
          }
        }
      }
    }
  }
;
  new Thread(r).start();
}

Fixed version (ground truth):
@Override public void unregisterService(String clusterId) throws UnregisteredClusterException {
  final String clusterId_=clusterId;
  Runnable terminateInTimeout=new Runnable(){
    @Override public void run(){
      ClusterContext ctxt=dataHolder.getClusterContext(clusterId_);
      if (ctxt == null) {
        String msg="String_Node_Str" + clusterId_;
        log.error(msg);
      }
      Collection<Member> members=TopologyManager.getTopology().getService(ctxt.getCartridgeType()).getCluster(clusterId_).getMembers();
      long endTime=System.currentTimeMillis() + ctxt.getTimeoutInMillis() * members.size();
      while (System.currentTimeMillis() < endTime) {
        CloudControllerUtil.sleep(1000);
      }
      if (members.size() > 0) {
        for (        Member member : members) {
          try {
            terminateInstance(member.getMemberId());
          }
 catch (          Exception e) {
            log.warn("String_Node_Str" + member.getMemberId(),e);
          }
        }
      }
    }
  }
;
  Runnable unregister=new Runnable(){
    public void run(){
      ClusterContext ctxt=dataHolder.getClusterContext(clusterId_);
      if (ctxt == null) {
        String msg="String_Node_Str" + clusterId_;
        log.error(msg);
      }
      Collection<Member> members=TopologyManager.getTopology().getService(ctxt.getCartridgeType()).getCluster(clusterId_).getMembers();
      long endTime=System.currentTimeMillis() + ctxt.getTimeoutInMillis() * members.size();
      while (members.size() > 0) {
        CloudControllerUtil.sleep(1000);
      }
      log.info("String_Node_Str" + clusterId_);
      deleteVolumes(ctxt);
      TopologyBuilder.handleClusterRemoved(ctxt);
      dataHolder.removeClusterContext(clusterId_);
      dataHolder.removeMemberContextsOfCluster(clusterId_);
      persist();
    }
    private void deleteVolumes(    ClusterContext ctxt){
      if (ctxt.isVolumeRequired()) {
        Cartridge cartridge=dataHolder.getCartridge(ctxt.getCartridgeType());
        if (cartridge != null && cartridge.getIaases() != null && !ctxt.getListOfVolumes().isEmpty()) {
          for (          Volume volume : ctxt.getListOfVolumes()) {
            if (volume.getId() != null) {
              String iaasType=volume.getIaasType();
              Iaas iaas=dataHolder.getIaasProvider(iaasType).getIaas();
              if (iaas != null) {
                try {
                  iaas.deleteVolume(volume.getId());
                }
 catch (                Exception ignore) {
                  if (log.isDebugEnabled()) {
                    log.debug(ignore);
                  }
                }
              }
            }
          }
        }
      }
    }
  }
;
  new Thread(terminateInTimeout).start();
  new Thread(unregister).start();
}