Program: 115628
Project: 115628
Buggy source:
private boolean createInstance(String parentInstanceId,Cluster cluster) throws PolicyValidationException, PartitionValidationException {
  Instance parentMonitorInstance=this.parent.getInstance(parentInstanceId);
  String partitionId=null;
  if (parentMonitorInstance instanceof GroupInstance) {
    partitionId=parentMonitorInstance.getPartitionId();
  }
  if (parentMonitorInstance != null) {
    ClusterInstance clusterInstance=cluster.getInstanceContexts(parentInstanceId);
    if (clusterInstance != null) {
      ClusterContext clusterContext=this.getClusterContext();
      if (clusterContext == null) {
        clusterContext=ClusterContextFactory.getVMClusterContext(clusterInstance.getInstanceId(),cluster,hasScalingDependents(),this.deploymentPolicyId);
        this.setClusterContext(clusterContext);
      }
      clusterContext.addInstanceContext(parentInstanceId,cluster,hasScalingDependents(),groupScalingEnabledSubtree());
      if (this.getInstance(clusterInstance.getInstanceId()) == null) {
        this.addInstance(clusterInstance);
      }
      boolean stateChanged=ServiceReferenceHolder.getInstance().getClusterStatusProcessorChain().process("String_Node_Str",cluster.getClusterId(),clusterInstance.getInstanceId());
      if (!stateChanged && clusterInstance.getStatus() != ClusterStatus.Created) {
        this.notifyParentMonitor(clusterInstance.getStatus(),clusterInstance.getInstanceId());
      }
      if (this.hasMonitoringStarted().compareAndSet(false,true)) {
        this.startScheduler();
        log.info(String.format("String_Node_Str",cluster.getClusterId()));
      }
    }
 else {
      createClusterInstance(cluster.getServiceName(),cluster.getClusterId(),null,parentInstanceId,partitionId,parentMonitorInstance.getNetworkPartitionId());
      log.debug(String.format("String_Node_Str" + "String_Node_Str",appId,cluster.getServiceName(),cluster.getClusterId()));
    }
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
private boolean createInstance(String parentInstanceId,Cluster cluster) throws PolicyValidationException, PartitionValidationException {
  Instance parentMonitorInstance=this.parent.getInstance(parentInstanceId);
  String partitionId=null;
  if (parentMonitorInstance instanceof GroupInstance) {
    partitionId=parentMonitorInstance.getPartitionId();
  }
  if (parentMonitorInstance != null) {
    ClusterInstance clusterInstance=cluster.getInstanceContexts(parentInstanceId);
    if (clusterInstance != null) {
      ClusterContext clusterContext=this.getClusterContext();
      if (clusterContext == null) {
        clusterContext=ClusterContextFactory.getVMClusterContext(clusterInstance.getInstanceId(),cluster,hasScalingDependents(),this.deploymentPolicyId);
        this.setClusterContext(clusterContext);
      }
      clusterContext.addInstanceContext(parentInstanceId,cluster,hasScalingDependents(),groupScalingEnabledSubtree());
      if (this.getInstance(clusterInstance.getInstanceId()) == null) {
        this.addInstance(clusterInstance);
      }
      boolean stateChanged=ServiceReferenceHolder.getInstance().getClusterStatusProcessorChain().process("String_Node_Str",cluster.getClusterId(),clusterInstance.getInstanceId());
      if (!stateChanged && clusterInstance.getStatus() != ClusterStatus.Created) {
        this.notifyParentMonitor(clusterInstance.getStatus(),clusterInstance.getInstanceId());
      }
      if (this.hasMonitoringStarted().compareAndSet(false,true)) {
        this.startScheduler();
        log.info(String.format("String_Node_Str",cluster.getClusterId()));
      }
    }
 else {
      createClusterInstance(cluster.getServiceName(),cluster.getClusterId(),null,parentInstanceId,partitionId,parentMonitorInstance.getNetworkPartitionId());
      if (log.isDebugEnabled()) {
        log.debug(String.format("String_Node_Str" + "String_Node_Str",appId,cluster.getServiceName(),cluster.getClusterId()));
      }
    }
    return true;
  }
 else {
    return false;
  }
}