Program: 116277
Project: 116277
Buggy source:
/** 
 * Updates ClusterContext for given cluster
 * @param parentMonitor parent of the monitor
 * @param context
 * @return ClusterMonitor - Updated ClusterContext
 * @throws org.apache.stratos.autoscaler.exception.PolicyValidationException
 * @throws org.apache.stratos.autoscaler.exception.PartitionValidationException
 */
public static AbstractClusterMonitor getClusterMonitor(ParentComponentMonitor parentMonitor,ClusterChildContext context,String appId,String instanceId) throws PolicyValidationException, PartitionValidationException, TopologyInConsistentException {
  String clusterId=context.getId();
  String serviceName=context.getServiceName();
  Cluster cluster;
  TopologyManager.acquireReadLockForCluster(serviceName,clusterId);
  try {
    Topology topology=TopologyManager.getTopology();
    if (topology.serviceExists(serviceName)) {
      Service service=topology.getService(serviceName);
      if (service.clusterExists(clusterId)) {
        cluster=service.getCluster(clusterId);
      }
 else {
        String msg="String_Node_Str" + clusterId + "String_Node_Str"+ "String_Node_Str"+ serviceName;
        throw new TopologyInConsistentException(msg);
      }
    }
 else {
      String msg="String_Node_Str" + serviceName + "String_Node_Str";
      throw new TopologyInConsistentException(msg);
    }
    AbstractClusterMonitor clusterMonitor=ClusterMonitorFactory.getMonitor(cluster);
    clusterMonitor.setParent(parentMonitor);
    clusterMonitor.setId(clusterId);
    if (parentMonitor.hasStartupDependents() || (context.hasStartupDependents() && context.hasChild())) {
      clusterMonitor.setHasStartupDependents(true);
    }
 else {
      clusterMonitor.setHasStartupDependents(false);
    }
    if (parentMonitor.isHasGroupScalingDependent() || (context.isGroupScalingEnabled())) {
      clusterMonitor.setHasGroupScalingDependent(true);
    }
 else {
      clusterMonitor.setHasGroupScalingDependent(false);
    }
    if (cluster.getStatus(null) != clusterMonitor.getStatus()) {
      clusterMonitor.setStatus(cluster.getStatus(null));
    }
 else {
      if (!cluster.hasMembers()) {
        StatusChecker.getInstance().onMemberStatusChange(clusterId);
      }
    }
    if (cluster.getInstanceContextCount() > 0) {
    }
    return clusterMonitor;
  }
  finally {
    TopologyManager.releaseReadLockForCluster(serviceName,clusterId);
  }
}

Fixed version (ground truth):
/** 
 * Updates ClusterContext for given cluster
 * @param parentMonitor parent of the monitor
 * @param context
 * @return ClusterMonitor - Updated ClusterContext
 * @throws org.apache.stratos.autoscaler.exception.PolicyValidationException
 * @throws org.apache.stratos.autoscaler.exception.PartitionValidationException
 */
public static AbstractClusterMonitor getClusterMonitor(ParentComponentMonitor parentMonitor,ClusterChildContext context,String appId,String instanceId) throws PolicyValidationException, PartitionValidationException, TopologyInConsistentException {
  String clusterId=context.getId();
  String serviceName=context.getServiceName();
  Cluster cluster;
  TopologyManager.acquireReadLockForCluster(serviceName,clusterId);
  try {
    Topology topology=TopologyManager.getTopology();
    if (topology.serviceExists(serviceName)) {
      Service service=topology.getService(serviceName);
      if (service.clusterExists(clusterId)) {
        cluster=service.getCluster(clusterId);
      }
 else {
        String msg="String_Node_Str" + clusterId + "String_Node_Str"+ "String_Node_Str"+ serviceName;
        throw new TopologyInConsistentException(msg);
      }
    }
 else {
      String msg="String_Node_Str" + serviceName + "String_Node_Str";
      throw new TopologyInConsistentException(msg);
    }
    AbstractClusterMonitor clusterMonitor=ClusterMonitorFactory.getMonitor(cluster);
    clusterMonitor.setParent(parentMonitor);
    clusterMonitor.setId(clusterId);
    if (parentMonitor.hasStartupDependents() || (context.hasStartupDependents() && context.hasChild())) {
      clusterMonitor.setHasStartupDependents(true);
    }
 else {
      clusterMonitor.setHasStartupDependents(false);
    }
    if (parentMonitor.isHasGroupScalingDependent() || (context.isGroupScalingEnabled())) {
      clusterMonitor.setHasGroupScalingDependent(true);
    }
 else {
      clusterMonitor.setHasGroupScalingDependent(false);
    }
    if (cluster.getInstanceContextCount() > 0) {
    }
    return clusterMonitor;
  }
  finally {
    TopologyManager.releaseReadLockForCluster(serviceName,clusterId);
  }
}