Program: 116301
Project: 116301
Buggy source:
/** 
 * This will build the dependency tree based on the given dependencies
 * @param component it will give the necessary information to build the tree
 * @return the dependency tree out of the dependency orders
 */
public DependencyTree buildDependency(ParentComponent component) throws DependencyBuilderException {
  String identifier=component.getUniqueIdentifier();
  DependencyTree dependencyTree=new DependencyTree(identifier);
  DependencyOrder dependencyOrder=component.getDependencyOrder();
  if (dependencyOrder != null) {
    log.info("String_Node_Str" + identifier);
    String terminationBehaviour=dependencyOrder.getTerminationBehaviour();
    if (Constants.TERMINATE_NONE.equals(terminationBehaviour)) {
      dependencyTree.setTerminationBehavior(DependencyTree.TerminationBehavior.TERMINATE_NONE);
    }
 else     if (Constants.TERMINATE_ALL.equals(terminationBehaviour)) {
      dependencyTree.setTerminationBehavior(DependencyTree.TerminationBehavior.TERMINATE_ALL);
    }
 else     if (Constants.TERMINATE_DEPENDENTS.equals(terminationBehaviour)) {
      dependencyTree.setTerminationBehavior(DependencyTree.TerminationBehavior.TERMINATE_DEPENDENT);
    }
    log.info("String_Node_Str" + terminationBehaviour + "String_Node_Str"+ "String_Node_Str"+ dependencyTree.getId());
    Set<StartupOrder> startupOrders=dependencyOrder.getStartupOrders();
    ApplicationChildContext foundContext;
    ApplicationChildContext parentContext;
    if (startupOrders != null) {
      for (      StartupOrder startupOrder : startupOrders) {
        parentContext=null;
        for (        String startupOrderComponent : startupOrder.getStartupOrderComponentList()) {
          if (startupOrderComponent != null) {
            ApplicationChildContext applicationContext=ApplicationChildContextFactory.getApplicationContext(startupOrderComponent,component,dependencyTree);
            String id=applicationContext.getId();
            ApplicationChildContext existingApplicationContext=dependencyTree.findApplicationContextWithIdInPrimaryTree(id);
            if (existingApplicationContext == null) {
              if (parentContext != null) {
                parentContext.addApplicationContext(applicationContext);
                parentContext=applicationContext;
                if (log.isDebugEnabled()) {
                  log.debug("String_Node_Str" + parentContext.getId() + "String_Node_Str"+ id+ "String_Node_Str");
                }
              }
 else {
                dependencyTree.addPrimaryApplicationContext(applicationContext);
                parentContext=applicationContext;
              }
            }
 else {
              if (parentContext == null) {
                existingApplicationContext.addApplicationContext(applicationContext);
                parentContext=existingApplicationContext;
                if (log.isDebugEnabled()) {
                  log.debug("String_Node_Str" + id + "String_Node_Str"+ "String_Node_Str");
                }
              }
 else {
                String msg="String_Node_Str" + "String_Node_Str";
                throw new DependencyBuilderException(msg);
              }
            }
          }
        }
      }
    }
    Set<ScalingOrder> scalingOrders=dependencyOrder.getScalingOrders();
    if (scalingOrders != null) {
      for (      ScalingOrder scalingOrder : scalingOrders) {
        foundContext=null;
        parentContext=null;
        for (        String scalingOrderComponent : scalingOrder.getScalingOrderComponentsList()) {
          if (scalingOrderComponent != null) {
            String applicationContextId=null;
            if (scalingOrderComponent.startsWith(Constants.GROUP + "String_Node_Str")) {
              applicationContextId=getGroupFromStartupOrder(scalingOrderComponent);
            }
 else             if (scalingOrderComponent.startsWith(Constants.CARTRIDGE + "String_Node_Str")) {
              applicationContextId=getClusterFromStartupOrder(scalingOrderComponent);
            }
 else {
              log.warn("String_Node_Str" + scalingOrderComponent + "String_Node_Str");
            }
            if (applicationContextId != null) {
              ApplicationChildContext applicationContext=dependencyTree.findApplicationContextWithIdInPrimaryTree(applicationContextId);
              ApplicationChildContext existingApplicationContext=dependencyTree.findApplicationContextWithIdInScalingDependencyTree(applicationContextId);
              if (existingApplicationContext == null) {
                if (parentContext != null) {
                  parentContext.setHasScalingDependents(true);
                  parentContext.addApplicationContext(applicationContext);
                  parentContext=applicationContext;
                  if (log.isDebugEnabled()) {
                    log.debug("String_Node_Str" + parentContext.getId() + "String_Node_Str"+ applicationContextId+ "String_Node_Str");
                  }
                }
 else {
                  dependencyTree.addScalingApplicationContext(applicationContext);
                  parentContext=applicationContext;
                }
              }
 else {
                String msg="String_Node_Str" + "String_Node_Str";
                throw new DependencyBuilderException(msg);
              }
            }
          }
        }
      }
    }
  }
  for (  Group group1 : component.getAliasToGroupMap().values()) {
    if (dependencyTree.findApplicationContextWithIdInPrimaryTree(group1.getAlias()) == null) {
      ApplicationChildContext context=ApplicationChildContextFactory.getGroupChildContext(group1.getAlias(),dependencyTree.isTerminateDependent());
      dependencyTree.addPrimaryApplicationContext(context);
    }
  }
  for (  ClusterDataHolder dataHolder : component.getClusterDataMap().values()) {
    if (dependencyTree.findApplicationContextWithIdInPrimaryTree(dataHolder.getClusterId()) == null) {
      ApplicationChildContext context=ApplicationChildContextFactory.getClusterChildContext(dataHolder,dependencyTree.isTerminateDependent());
      dependencyTree.addPrimaryApplicationContext(context);
    }
  }
  return dependencyTree;
}

Fixed version (ground truth):
/** 
 * This will build the dependency tree based on the given dependencies
 * @param component it will give the necessary information to build the tree
 * @return the dependency tree out of the dependency orders
 */
public DependencyTree buildDependency(ParentComponent component) throws DependencyBuilderException {
  String identifier=component.getUniqueIdentifier();
  DependencyTree dependencyTree=new DependencyTree(identifier);
  DependencyOrder dependencyOrder=component.getDependencyOrder();
  if (dependencyOrder != null) {
    log.info("String_Node_Str" + identifier);
    String terminationBehaviour=dependencyOrder.getTerminationBehaviour();
    if (Constants.TERMINATE_NONE.equals(terminationBehaviour)) {
      dependencyTree.setTerminationBehavior(DependencyTree.TerminationBehavior.TERMINATE_NONE);
    }
 else     if (Constants.TERMINATE_ALL.equals(terminationBehaviour)) {
      dependencyTree.setTerminationBehavior(DependencyTree.TerminationBehavior.TERMINATE_ALL);
    }
 else     if (Constants.TERMINATE_DEPENDENTS.equals(terminationBehaviour)) {
      dependencyTree.setTerminationBehavior(DependencyTree.TerminationBehavior.TERMINATE_DEPENDENT);
    }
    log.info("String_Node_Str" + terminationBehaviour + "String_Node_Str"+ "String_Node_Str"+ dependencyTree.getId());
    Set<StartupOrder> startupOrders=dependencyOrder.getStartupOrders();
    ApplicationChildContext foundContext;
    ApplicationChildContext parentContext;
    if (startupOrders != null) {
      for (      StartupOrder startupOrder : startupOrders) {
        parentContext=null;
        for (        String startupOrderComponent : startupOrder.getStartupOrderComponentList()) {
          if (startupOrderComponent != null) {
            ApplicationChildContext applicationContext=ApplicationChildContextFactory.getApplicationContext(startupOrderComponent,component,dependencyTree);
            String id=applicationContext.getId();
            ApplicationChildContext existingApplicationContext=dependencyTree.findApplicationContextWithIdInPrimaryTree(id);
            if (existingApplicationContext == null) {
              if (parentContext != null) {
                parentContext.addApplicationContext(applicationContext);
                parentContext=applicationContext;
                if (log.isDebugEnabled()) {
                  log.debug("String_Node_Str" + parentContext.getId() + "String_Node_Str"+ id+ "String_Node_Str");
                }
              }
 else {
                dependencyTree.addPrimaryApplicationContext(applicationContext);
                parentContext=applicationContext;
              }
            }
 else {
              if (parentContext == null) {
                existingApplicationContext.addApplicationContext(applicationContext);
                parentContext=existingApplicationContext;
                if (log.isDebugEnabled()) {
                  log.debug("String_Node_Str" + id + "String_Node_Str"+ "String_Node_Str");
                }
              }
 else {
                String msg="String_Node_Str" + "String_Node_Str";
                throw new DependencyBuilderException(msg);
              }
            }
          }
        }
      }
    }
    Set<ScalingOrder> scalingOrders=dependencyOrder.getScalingOrders();
    if (scalingOrders != null) {
      for (      ScalingOrder scalingOrder : scalingOrders) {
        foundContext=null;
        parentContext=null;
        for (        String scalingOrderComponent : scalingOrder.getScalingOrderComponentsList()) {
          if (scalingOrderComponent != null) {
            String applicationContextId=null;
            if (scalingOrderComponent.startsWith(Constants.GROUP + "String_Node_Str")) {
              applicationContextId=getGroupFromStartupOrder(scalingOrderComponent);
            }
 else             if (scalingOrderComponent.startsWith(Constants.CARTRIDGE + "String_Node_Str")) {
              applicationContextId=getClusterFromStartupOrder(scalingOrderComponent);
            }
 else {
              log.warn("String_Node_Str" + scalingOrderComponent + "String_Node_Str");
            }
            if (applicationContextId != null) {
              ApplicationChildContext applicationContext=dependencyTree.findApplicationContextWithIdInPrimaryTree(applicationContextId);
              ApplicationChildContext existingApplicationContext=dependencyTree.findApplicationContextWithIdInScalingDependencyTree(applicationContextId);
              if (existingApplicationContext == null) {
                if (parentContext != null) {
                  parentContext.setGroupScalingEnabled(true);
                  parentContext.addApplicationContext(applicationContext);
                  parentContext=applicationContext;
                  if (log.isDebugEnabled()) {
                    log.debug("String_Node_Str" + parentContext.getId() + "String_Node_Str"+ applicationContextId+ "String_Node_Str");
                  }
                }
 else {
                  dependencyTree.addScalingApplicationContext(applicationContext);
                  parentContext=applicationContext;
                }
              }
 else {
                String msg="String_Node_Str" + "String_Node_Str";
                throw new DependencyBuilderException(msg);
              }
            }
          }
        }
      }
    }
  }
  for (  Group group1 : component.getAliasToGroupMap().values()) {
    if (dependencyTree.findApplicationContextWithIdInPrimaryTree(group1.getAlias()) == null) {
      ApplicationChildContext context=ApplicationChildContextFactory.getGroupChildContext(group1.getAlias(),dependencyTree.isTerminateDependent());
      dependencyTree.addPrimaryApplicationContext(context);
    }
  }
  for (  ClusterDataHolder dataHolder : component.getClusterDataMap().values()) {
    if (dependencyTree.findApplicationContextWithIdInPrimaryTree(dataHolder.getClusterId()) == null) {
      ApplicationChildContext context=ApplicationChildContextFactory.getClusterChildContext(dataHolder,dependencyTree.isTerminateDependent());
      dependencyTree.addPrimaryApplicationContext(context);
    }
  }
  return dependencyTree;
}