Program: 63992
Project: 63992
Buggy source:
@Override public void accept(Event<StackStatusUpdateRequest> event){
  StackStatusUpdateRequest statusUpdateRequest=event.getData();
  final CloudPlatform cloudPlatform=statusUpdateRequest.getCloudPlatform();
  StatusRequest statusRequest=statusUpdateRequest.getStatusRequest();
  long stackId=statusUpdateRequest.getStackId();
  Stack stack=stackRepository.findOneWithLists(stackId);
  MDCBuilder.buildMdcContext(stack);
  if (StatusRequest.STOPPED.equals(statusRequest)) {
    cloudbreakEventService.fireCloudbreakEvent(stackId,Status.STOP_IN_PROGRESS.name(),"String_Node_Str");
    boolean stopped;
    if (cloudPlatform.isWithTemplate()) {
      CloudPlatformConnector connector=cloudPlatformConnectors.get(cloudPlatform);
      stopped=connector.stopAll(stack);
    }
 else {
      stopped=startStopResources(cloudPlatform,stack,false);
    }
    if (stopped) {
      LOGGER.info("String_Node_Str",Status.STOPPED);
      stackUpdater.updateStackStatus(stackId,Status.STOPPED,"String_Node_Str");
      cloudbreakEventService.fireCloudbreakEvent(stackId,BillingStatus.BILLING_STOPPED.name(),"String_Node_Str");
    }
 else {
      LOGGER.info("String_Node_Str",Status.STOP_FAILED);
      stackUpdater.updateStackStatus(stackId,Status.STOP_FAILED,"String_Node_Str");
    }
  }
 else {
    boolean started;
    if (cloudPlatform.isWithTemplate()) {
      CloudPlatformConnector connector=cloudPlatformConnectors.get(cloudPlatform);
      started=connector.startAll(stack);
    }
 else {
      started=startStopResources(cloudPlatform,stack,true);
    }
    if (started) {
      waitForAmbariToStart(stack);
      Cluster cluster=clusterRepository.findOneWithLists(stack.getCluster().getId());
      LOGGER.info("String_Node_Str",Status.AVAILABLE);
      String statusReason="String_Node_Str" + stack.getAmbariIp();
      stackUpdater.updateStackStatus(stackId,Status.AVAILABLE,statusReason);
      if (cluster != null && Status.START_REQUESTED.equals(cluster.getStatus())) {
        boolean hostsJoined=waitForHostsToJoin(stack);
        if (hostsJoined) {
          cloudbreakEventService.fireCloudbreakEvent(stackId,Status.START_IN_PROGRESS.name(),"String_Node_Str");
          reactor.notify(ReactorConfig.CLUSTER_STATUS_UPDATE_EVENT,Event.wrap(new ClusterStatusUpdateRequest(stack.getId(),statusRequest)));
        }
 else {
          cluster.setStatus(Status.START_FAILED);
          clusterRepository.save(cluster);
          stackUpdater.updateStackStatus(stackId,Status.AVAILABLE,"String_Node_Str");
        }
      }
    }
 else {
      LOGGER.info("String_Node_Str",Status.START_FAILED);
      stackUpdater.updateStackStatus(stackId,Status.START_FAILED,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
@Override public void accept(Event<StackStatusUpdateRequest> event){
  StackStatusUpdateRequest statusUpdateRequest=event.getData();
  final CloudPlatform cloudPlatform=statusUpdateRequest.getCloudPlatform();
  StatusRequest statusRequest=statusUpdateRequest.getStatusRequest();
  long stackId=statusUpdateRequest.getStackId();
  Stack stack=stackRepository.findOneWithLists(stackId);
  MDCBuilder.buildMdcContext(stack);
  if (StatusRequest.STOPPED.equals(statusRequest)) {
    cloudbreakEventService.fireCloudbreakEvent(stackId,Status.STOP_IN_PROGRESS.name(),"String_Node_Str");
    boolean stopped;
    if (cloudPlatform.isWithTemplate()) {
      CloudPlatformConnector connector=cloudPlatformConnectors.get(cloudPlatform);
      stopped=connector.stopAll(stack);
    }
 else {
      stopped=startStopResources(cloudPlatform,stack,false);
    }
    if (stopped) {
      LOGGER.info("String_Node_Str",Status.STOPPED);
      stackUpdater.updateStackStatus(stackId,Status.STOPPED,"String_Node_Str");
      cloudbreakEventService.fireCloudbreakEvent(stackId,BillingStatus.BILLING_STOPPED.name(),"String_Node_Str");
    }
 else {
      LOGGER.info("String_Node_Str",Status.STOP_FAILED);
      stackUpdater.updateStackStatus(stackId,Status.STOP_FAILED,"String_Node_Str");
    }
  }
 else {
    boolean started;
    if (cloudPlatform.isWithTemplate()) {
      CloudPlatformConnector connector=cloudPlatformConnectors.get(cloudPlatform);
      started=connector.startAll(stack);
    }
 else {
      started=startStopResources(cloudPlatform,stack,true);
    }
    if (started) {
      waitForAmbariToStart(stack);
      Cluster cluster=clusterRepository.findOneWithLists(stack.getCluster().getId());
      boolean hostsJoined=waitForHostsToJoin(stack);
      if (hostsJoined) {
        String statusReason="String_Node_Str" + stack.getAmbariIp();
        LOGGER.info("String_Node_Str",Status.AVAILABLE);
        stackUpdater.updateStackStatus(stackId,Status.AVAILABLE,statusReason);
      }
      if (hostsJoined && cluster != null && Status.START_REQUESTED.equals(cluster.getStatus())) {
        cloudbreakEventService.fireCloudbreakEvent(stackId,Status.START_IN_PROGRESS.name(),"String_Node_Str");
        reactor.notify(ReactorConfig.CLUSTER_STATUS_UPDATE_EVENT,Event.wrap(new ClusterStatusUpdateRequest(stack.getId(),statusRequest)));
      }
 else       if (!hostsJoined && cluster != null && Status.START_REQUESTED.equals(cluster.getStatus())) {
        cluster.setStatus(Status.START_FAILED);
        clusterRepository.save(cluster);
        stackUpdater.updateStackStatus(stackId,Status.AVAILABLE,"String_Node_Str");
      }
    }
 else {
      LOGGER.info("String_Node_Str",Status.START_FAILED);
      stackUpdater.updateStackStatus(stackId,Status.START_FAILED,"String_Node_Str");
    }
  }
}