Program: 116028
Project: 116028
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=(ClusterContext)this.getClusterContext();
      if (clusterContext == null) {
        clusterContext=ClusterContextFactory.getVMClusterContext(clusterInstance.getInstanceId(),cluster,hasScalingDependents());
        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_Node_Str" + cluster.getClusterId() + "String_Node_Str");
        }
      }
    }
 else {
      createClusterInstance(cluster.getServiceName(),cluster.getClusterId(),null,parentInstanceId,partitionId,parentMonitorInstance.getNetworkPartitionId());
    }
    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=(ClusterContext)this.getClusterContext();
      if (clusterContext == null) {
        clusterContext=ClusterContextFactory.getVMClusterContext(clusterInstance.getInstanceId(),cluster,hasScalingDependents());
        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_Node_Str" + cluster.getClusterId() + "String_Node_Str");
      }
    }
 else {
      createClusterInstance(cluster.getServiceName(),cluster.getClusterId(),null,parentInstanceId,partitionId,parentMonitorInstance.getNetworkPartitionId());
    }
    return true;
  }
 else {
    return false;
  }
}