Program: 116368
Project: 116368
Buggy source:
@Override public MemberContext[] startContainers(ContainerClusterContext containerClusterContext) throws UnregisteredCartridgeException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str");
  }
  handleNullObject(containerClusterContext,"String_Node_Str");
  String clusterId=containerClusterContext.getClusterId();
  handleNullObject(clusterId,"String_Node_Str");
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + containerClusterContext.toString());
  }
  ClusterContext ctxt=dataHolder.getClusterContext(clusterId);
  handleNullObject(ctxt,"String_Node_Str" + containerClusterContext.toString());
  String cartridgeType=ctxt.getCartridgeType();
  Cartridge cartridge=dataHolder.getCartridge(cartridgeType);
  if (cartridge == null) {
    String msg="String_Node_Str" + cartridgeType + "String_Node_Str"+ containerClusterContext.toString();
    LOG.error(msg);
    throw new UnregisteredCartridgeException(msg);
  }
  try {
    String minReplicas=validateProperty(StratosConstants.KUBERNETES_MIN_REPLICAS,ctxt);
    String kubernetesClusterId=validateProperty(StratosConstants.KUBERNETES_CLUSTER_ID,ctxt);
    String kubernetesMasterIp=validateProperty(StratosConstants.KUBERNETES_MASTER_IP,containerClusterContext);
    String kubernetesPortRange=validateProperty(StratosConstants.KUBERNETES_PORT_RANGE,containerClusterContext);
    KubernetesClusterContext kubClusterContext=getKubernetesClusterContext(kubernetesClusterId,kubernetesMasterIp,kubernetesPortRange);
    KubernetesApiClient kubApi=kubClusterContext.getKubApi();
    ContainerClusterContextToReplicationController controllerFunction=new ContainerClusterContextToReplicationController();
    ReplicationController controller=controllerFunction.apply(containerClusterContext);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + controller + "String_Node_Str"+ containerClusterContext+ "String_Node_Str");
    }
    kubApi.createReplicationController(controller);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + controller + "String_Node_Str");
    }
    ContainerClusterContextToKubernetesService serviceFunction=new ContainerClusterContextToKubernetesService();
    Service service=serviceFunction.apply(containerClusterContext);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + service + "String_Node_Str"+ containerClusterContext+ "String_Node_Str");
    }
    kubApi.createService(service);
    ctxt.addProperty(StratosConstants.ALLOCATED_SERVICE_HOST_PORT,service.getPort());
    dataHolder.addClusterContext(ctxt);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + controller + "String_Node_Str");
    }
    Label l=new Label();
    l.setName(clusterId);
    Pod[] newlyCreatedPods=new Pod[0];
    int expectedCount=Integer.parseInt(minReplicas);
    for (int i=0; i < expectedCount; i++) {
      newlyCreatedPods=kubApi.getSelectedPods(new Label[]{l});
      if (LOG.isDebugEnabled()) {
        LOG.debug("String_Node_Str" + newlyCreatedPods.length + "String_Node_Str"+ clusterId);
      }
      if (newlyCreatedPods.length == expectedCount) {
        break;
      }
      Thread.sleep(10000);
    }
    if (newlyCreatedPods.length == 0) {
      if (LOG.isDebugEnabled()) {
        LOG.debug(String.format("String_Node_Str",clusterId));
      }
      terminateAllContainers(clusterId);
      return new MemberContext[0];
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug(String.format("String_Node_Str",newlyCreatedPods.length,clusterId));
    }
    List<MemberContext> memberContexts=new ArrayList<MemberContext>();
    PodToMemberContext podToMemberContextFunc=new PodToMemberContext();
    for (    Pod pod : newlyCreatedPods) {
      MemberContext context=podToMemberContextFunc.apply(pod);
      context.setCartridgeType(cartridgeType);
      context.setClusterId(clusterId);
      context.setProperties(CloudControllerUtil.addProperty(context.getProperties(),StratosConstants.ALLOCATED_SERVICE_HOST_PORT,String.valueOf(service.getPort())));
      dataHolder.addMemberContext(context);
      ScheduledThreadExecutor exec=ScheduledThreadExecutor.getInstance();
      if (LOG.isDebugEnabled()) {
        LOG.debug("String_Node_Str");
      }
      dataHolder.addScheduledFutureJob(context.getMemberId(),exec.schedule(new PodActivationWatcher(pod.getId(),context,kubApi),5000));
      memberContexts.add(context);
    }
    persist();
    LOG.info("String_Node_Str" + memberContexts);
    return memberContexts.toArray(new MemberContext[0]);
  }
 catch (  Exception e) {
    String msg="String_Node_Str" + containerClusterContext.toString() + "String_Node_Str"+ e.getMessage();
    LOG.error(msg,e);
    throw new IllegalStateException(msg,e);
  }
}

Fixed version (ground truth):
@Override public MemberContext[] startContainers(ContainerClusterContext containerClusterContext) throws UnregisteredCartridgeException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str");
  }
  handleNullObject(containerClusterContext,"String_Node_Str");
  String clusterId=containerClusterContext.getClusterId();
  handleNullObject(clusterId,"String_Node_Str");
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + containerClusterContext.toString());
  }
  ClusterContext ctxt=dataHolder.getClusterContext(clusterId);
  handleNullObject(ctxt,"String_Node_Str" + containerClusterContext.toString());
  String cartridgeType=ctxt.getCartridgeType();
  Cartridge cartridge=dataHolder.getCartridge(cartridgeType);
  if (cartridge == null) {
    String msg="String_Node_Str" + cartridgeType + "String_Node_Str"+ containerClusterContext.toString();
    LOG.error(msg);
    throw new UnregisteredCartridgeException(msg);
  }
  try {
    String minReplicas=validateProperty(StratosConstants.KUBERNETES_MIN_REPLICAS,ctxt);
    String kubernetesClusterId=validateProperty(StratosConstants.KUBERNETES_CLUSTER_ID,ctxt);
    String kubernetesMasterIp=validateProperty(StratosConstants.KUBERNETES_MASTER_IP,containerClusterContext);
    String kubernetesPortRange=validateProperty(StratosConstants.KUBERNETES_PORT_RANGE,containerClusterContext);
    KubernetesClusterContext kubClusterContext=getKubernetesClusterContext(kubernetesClusterId,kubernetesMasterIp,kubernetesPortRange);
    KubernetesApiClient kubApi=kubClusterContext.getKubApi();
    ContainerClusterContextToReplicationController controllerFunction=new ContainerClusterContextToReplicationController();
    ReplicationController controller=controllerFunction.apply(containerClusterContext);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + controller + "String_Node_Str"+ containerClusterContext+ "String_Node_Str");
    }
    kubApi.createReplicationController(controller);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + controller + "String_Node_Str");
    }
    ContainerClusterContextToKubernetesService serviceFunction=new ContainerClusterContextToKubernetesService();
    Service service=serviceFunction.apply(containerClusterContext);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + service + "String_Node_Str"+ containerClusterContext+ "String_Node_Str");
    }
    kubApi.createService(service);
    Property[] properties=new Property[1];
    Property property=new Property(StratosConstants.ALLOCATED_SERVICE_HOST_PORT,String.valueOf(service.getPort()));
    org.apache.stratos.common.Properties properties1=new org.apache.stratos.common.Properties();
    properties1.setProperties(properties);
    ctxt.setProperties(properties1);
    dataHolder.addClusterContext(ctxt);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + controller + "String_Node_Str");
    }
    Label l=new Label();
    l.setName(clusterId);
    Pod[] newlyCreatedPods=new Pod[0];
    int expectedCount=Integer.parseInt(minReplicas);
    for (int i=0; i < expectedCount; i++) {
      newlyCreatedPods=kubApi.getSelectedPods(new Label[]{l});
      if (LOG.isDebugEnabled()) {
        LOG.debug("String_Node_Str" + newlyCreatedPods.length + "String_Node_Str"+ clusterId);
      }
      if (newlyCreatedPods.length == expectedCount) {
        break;
      }
      Thread.sleep(10000);
    }
    if (newlyCreatedPods.length == 0) {
      if (LOG.isDebugEnabled()) {
        LOG.debug(String.format("String_Node_Str",clusterId));
      }
      terminateAllContainers(clusterId);
      return new MemberContext[0];
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug(String.format("String_Node_Str",newlyCreatedPods.length,clusterId));
    }
    List<MemberContext> memberContexts=new ArrayList<MemberContext>();
    PodToMemberContext podToMemberContextFunc=new PodToMemberContext();
    for (    Pod pod : newlyCreatedPods) {
      MemberContext context=podToMemberContextFunc.apply(pod);
      context.setCartridgeType(cartridgeType);
      context.setClusterId(clusterId);
      context.setProperties(CloudControllerUtil.addProperty(context.getProperties(),StratosConstants.ALLOCATED_SERVICE_HOST_PORT,String.valueOf(service.getPort())));
      dataHolder.addMemberContext(context);
      ScheduledThreadExecutor exec=ScheduledThreadExecutor.getInstance();
      if (LOG.isDebugEnabled()) {
        LOG.debug("String_Node_Str");
      }
      dataHolder.addScheduledFutureJob(context.getMemberId(),exec.schedule(new PodActivationWatcher(pod.getId(),context,kubApi),5000));
      memberContexts.add(context);
    }
    persist();
    LOG.info("String_Node_Str" + memberContexts);
    return memberContexts.toArray(new MemberContext[0]);
  }
 catch (  Exception e) {
    String msg="String_Node_Str" + containerClusterContext.toString() + "String_Node_Str"+ e.getMessage();
    LOG.error(msg,e);
    throw new IllegalStateException(msg,e);
  }
}