Program: 115467
Project: 115467
Buggy source:
/** 
 * Terminate all the containers belong to a cluster by cluster id.
 * @param clusterId
 * @return
 * @throws InvalidClusterException
 */
public MemberContext[] terminateContainers(String clusterId) throws InvalidClusterException {
  Lock lock=null;
  try {
    lock=CloudControllerContext.getInstance().acquireMemberContextWriteLock();
    ClusterContext clusterContext=CloudControllerContext.getInstance().getClusterContext(clusterId);
    handleNullObject(clusterContext,"String_Node_Str" + clusterId);
    String kubernetesClusterId=clusterContext.getKubernetesClusterId();
    handleNullObject(kubernetesClusterId,"String_Node_Str" + "String_Node_Str" + clusterId);
    KubernetesClusterContext kubClusterContext=CloudControllerContext.getInstance().getKubernetesClusterContext(kubernetesClusterId);
    handleNullObject(kubClusterContext,"String_Node_Str" + "String_Node_Str" + kubernetesClusterId);
    KubernetesApiClient kubApi=kubClusterContext.getKubApi();
    List<KubernetesService> kubernetesServices=Lists.newArrayList(clusterContext.getKubernetesServices());
    if (kubernetesServices != null) {
      for (      KubernetesService kubernetesService : kubernetesServices) {
        try {
          String serviceId=kubernetesService.getId();
          kubApi.deleteService(serviceId);
          kubClusterContext.deallocatePort(kubernetesService.getPort());
          kubClusterContext.removeKubernetesService(serviceId);
          clusterContext.removeKubernetesService(serviceId);
        }
 catch (        KubernetesClientException e) {
          log.error("String_Node_Str" + clusterId,e);
        }
      }
    }
    List<MemberContext> memberContextsRemoved=new ArrayList<MemberContext>();
    List<MemberContext> memberContexts=CloudControllerContext.getInstance().getMemberContextsOfClusterId(clusterId);
    if (memberContexts != null) {
      for (      MemberContext memberContext : memberContexts) {
        try {
          MemberContext memberContextRemoved=terminateContainer(memberContext.getMemberId());
          memberContextsRemoved.add(memberContextRemoved);
        }
 catch (        MemberTerminationFailedException e) {
          String message="String_Node_Str" + memberContext.getMemberId();
          log.error(message);
        }
      }
    }
    CloudControllerContext.getInstance().persist();
    return memberContextsRemoved.toArray(new MemberContext[memberContextsRemoved.size()]);
  }
  finally {
    if (lock != null) {
      CloudControllerContext.getInstance().releaseWriteLock(lock);
    }
  }
}

Fixed version (ground truth):
/** 
 * Terminate all the containers belong to a cluster by cluster id.
 * @param clusterId
 * @return
 * @throws InvalidClusterException
 */
public MemberContext[] terminateContainers(String clusterId) throws InvalidClusterException {
  Lock lock=null;
  try {
    lock=CloudControllerContext.getInstance().acquireMemberContextWriteLock();
    ClusterContext clusterContext=CloudControllerContext.getInstance().getClusterContext(clusterId);
    handleNullObject(clusterContext,"String_Node_Str" + clusterId);
    String kubernetesClusterId=clusterContext.getKubernetesClusterId();
    handleNullObject(kubernetesClusterId,"String_Node_Str" + "String_Node_Str" + clusterId);
    KubernetesClusterContext kubClusterContext=CloudControllerContext.getInstance().getKubernetesClusterContext(kubernetesClusterId);
    handleNullObject(kubClusterContext,"String_Node_Str" + "String_Node_Str" + kubernetesClusterId);
    KubernetesApiClient kubApi=kubClusterContext.getKubApi();
    List<KubernetesService> kubernetesServices=Lists.newArrayList(clusterContext.getKubernetesServices());
    if (kubernetesServices != null) {
      for (      KubernetesService kubernetesService : kubernetesServices) {
        try {
          String serviceId=kubernetesService.getId();
          kubApi.deleteService(serviceId);
          kubClusterContext.deallocatePort(kubernetesService.getPort());
          kubClusterContext.removeKubernetesService(serviceId);
          clusterContext.removeKubernetesService(serviceId);
        }
 catch (        KubernetesClientException e) {
          log.error("String_Node_Str" + clusterId,e);
        }
      }
    }
    List<MemberContext> memberContextsRemoved=new ArrayList<MemberContext>();
    List<MemberContext> memberContexts=CloudControllerContext.getInstance().getMemberContextsOfClusterId(clusterId);
    if (memberContexts != null) {
      for (      MemberContext memberContext : memberContexts) {
        try {
          MemberContext memberContextRemoved=terminateContainer(memberContext);
          memberContextsRemoved.add(memberContextRemoved);
        }
 catch (        MemberTerminationFailedException e) {
          String message="String_Node_Str" + memberContext.getMemberId();
          log.error(message);
        }
      }
    }
    CloudControllerContext.getInstance().persist();
    return memberContextsRemoved.toArray(new MemberContext[memberContextsRemoved.size()]);
  }
  finally {
    if (lock != null) {
      CloudControllerContext.getInstance().releaseWriteLock(lock);
    }
  }
}