Program: 116207
Project: 116207
Buggy source:
/** 
 * This will start the group instance based on the given parent instanceId
 * @param group
 * @param parentInstanceId
 * @throws ParentMonitorNotFoundException
 */
public void createInstanceAndStartDependency(Group group,String parentInstanceId) throws ParentMonitorNotFoundException {
  String deploymentPolicyName=group.getDeploymentPolicy();
  String instanceId;
  Application application=ApplicationHolder.getApplications().getApplication(this.appId);
  Instance parentInstanceContext;
  if (this.id.equals(appId)) {
    parentInstanceContext=application.getInstanceContexts(parentInstanceId);
  }
 else {
    Group group1=application.getGroupRecursively(this.parent.getId());
    parentInstanceContext=group1.getInstanceContexts(parentInstanceId);
  }
  GroupLevelNetworkPartitionContext groupLevelNetworkPartitionContext;
  if (this.networkPartitionCtxts.containsKey(parentInstanceContext)) {
    groupLevelNetworkPartitionContext=this.networkPartitionCtxts.get(parentInstanceContext.getNetworkPartitionId());
  }
 else {
    groupLevelNetworkPartitionContext=new GroupLevelNetworkPartitionContext(parentInstanceContext.getNetworkPartitionId(),null,null);
    this.addNetworkPartitionContext(groupLevelNetworkPartitionContext);
  }
  String partitionId=null;
  String networkPartitionId=parentInstanceContext.getNetworkPartitionId();
  ChildPolicy policy=PolicyManager.getInstance().getDeploymentPolicyByApplication(group.getApplicationId()).getChildPolicy(group.getUniqueIdentifier());
  ChildLevelNetworkPartition networkPartition=policy.getChildLevelNetworkPartition(parentInstanceContext.getNetworkPartitionId());
  if (policy != null) {
    AutoscaleAlgorithm algorithm=this.getAutoscaleAlgorithm(networkPartition.getPartitionAlgo());
  }
  instanceId=createGroupInstance(group,parentInstanceId,partitionId,networkPartitionId);
  startDependency(group,instanceId);
}

Fixed version (ground truth):
/** 
 * This will start the group instance based on the given parent instanceId
 * @param group
 * @param parentInstanceId
 * @throws org.apache.stratos.autoscaler.exception.application.MonitorNotFoundException
 */
public void createInstanceAndStartDependency(Group group,String parentInstanceId) throws MonitorNotFoundException {
  String deploymentPolicyName=group.getDeploymentPolicy();
  String instanceId;
  Application application=ApplicationHolder.getApplications().getApplication(this.appId);
  Instance parentInstanceContext;
  if (this.id.equals(appId)) {
    parentInstanceContext=application.getInstanceContexts(parentInstanceId);
  }
 else {
    Group group1=application.getGroupRecursively(this.parent.getId());
    parentInstanceContext=group1.getInstanceContexts(parentInstanceId);
  }
  GroupLevelNetworkPartitionContext groupLevelNetworkPartitionContext;
  if (this.networkPartitionCtxts.containsKey(parentInstanceContext)) {
    groupLevelNetworkPartitionContext=this.networkPartitionCtxts.get(parentInstanceContext.getNetworkPartitionId());
  }
 else {
    groupLevelNetworkPartitionContext=new GroupLevelNetworkPartitionContext(parentInstanceContext.getNetworkPartitionId(),null,null);
    this.addNetworkPartitionContext(groupLevelNetworkPartitionContext);
  }
  String partitionId=null;
  String networkPartitionId=parentInstanceContext.getNetworkPartitionId();
  ChildPolicy policy=PolicyManager.getInstance().getDeploymentPolicyByApplication(group.getApplicationId()).getChildPolicy(group.getUniqueIdentifier());
  ChildLevelNetworkPartition networkPartition=policy.getChildLevelNetworkPartition(parentInstanceContext.getNetworkPartitionId());
  if (policy != null) {
    AutoscaleAlgorithm algorithm=this.getAutoscaleAlgorithm(networkPartition.getPartitionAlgo());
  }
  instanceId=createGroupInstance(group,parentInstanceId,partitionId,networkPartitionId);
  startDependency(group,instanceId);
}