Program: 115434
Project: 115434
Buggy source:
/** 
 * Builds the Application structure
 * @param applicationContext    ApplicationContext object with Application information
 * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information
 * @return Application Application object denoting the Application structure
 * @throws ApplicationDefinitionException If an error occurs in building the Application structure
 */
private Application buildCompositeAppStructure(ApplicationContext applicationContext,Map<String,SubscribableInfoContext> subscribableInfoCtxts) throws ApplicationDefinitionException, CartridgeGroupNotFoundException, CartridgeNotFoundException {
  Application application=new Application(applicationContext.getApplicationId());
  application.setTenantId(applicationContext.getTenantId());
  application.setTenantDomain(applicationContext.getTenantDomain());
  application.setTenantAdminUserName(applicationContext.getTenantAdminUsername());
  Set<StartupOrder> startupOrderSet=new LinkedHashSet<StartupOrder>();
  DependencyOrder dependencyOrder=new DependencyOrder();
  dependencyOrder.setStartupOrders(startupOrderSet);
  application.setDependencyOrder(dependencyOrder);
  ComponentContext components=applicationContext.getComponents();
  if (components != null) {
    DependencyContext dependencyContext=components.getDependencyContext();
    if (dependencyContext != null) {
      String[] startupOrders=dependencyContext.getStartupOrdersContexts();
      if (startupOrders != null) {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + applicationContext.getAlias() + "String_Node_Str"+ startupOrders.length);
        }
        ParserUtils.validateStartupOrderAlias(startupOrders,applicationContext);
        dependencyOrder.setStartupOrders(ParserUtils.convertStartupOrder(startupOrders));
      }
 else {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + applicationContext.getAlias());
        }
      }
      String[] scalingDependents=dependencyContext.getScalingDependents();
      if (scalingDependents != null) {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + applicationContext.getAlias() + "String_Node_Str"+ scalingDependents.length);
        }
        dependencyOrder.setScalingDependents(ParserUtils.convertScalingDependentList(scalingDependents));
      }
 else {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + applicationContext.getAlias());
        }
      }
      String terminationBehaviour=dependencyContext.getTerminationBehaviour();
      validateTerminationBehavior(terminationBehaviour);
      dependencyOrder.setTerminationBehaviour(terminationBehaviour);
    }
    CartridgeContext[] cartridgeContexts=components.getCartridgeContexts();
    if (cartridgeContexts != null) {
      List<CartridgeContext> cartridgeContextList=Arrays.asList(cartridgeContexts);
      Set<StartupOrder> startupOrders=application.getDependencyOrder().getStartupOrders();
      Map<String,Map<String,ClusterDataHolder>> clusterDataMap;
      clusterDataMap=parseLeafLevelSubscriptions(applicationContext.getApplicationId(),applicationContext.getTenantId(),application.getKey(),null,cartridgeContextList,startupOrders);
      application.setClusterData(clusterDataMap.get(ALIAS));
      application.setClusterDataForType(clusterDataMap.get(CARTRIDGE_TYPE));
    }
    if (components.getGroupContexts() != null) {
      application.setGroups(parseGroups(applicationContext.getApplicationId(),applicationContext.getTenantId(),application.getKey(),Arrays.asList(components.getGroupContexts()),subscribableInfoCtxts));
    }
  }
  application.setAliasToDeploymentPolicyIdMap(AutoscalerUtil.getAliasToDeploymentPolicyIdMapOfApplication(applicationContext));
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + applicationContext.getApplicationId());
  }
  return application;
}

Fixed version (ground truth):
/** 
 * Builds the Application structure
 * @param applicationContext    ApplicationContext object with Application information
 * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information
 * @return Application Application object denoting the Application structure
 * @throws ApplicationDefinitionException If an error occurs in building the Application structure
 */
private Application buildCompositeAppStructure(ApplicationContext applicationContext,Map<String,SubscribableInfoContext> subscribableInfoCtxts) throws ApplicationDefinitionException, CartridgeGroupNotFoundException, CartridgeNotFoundException {
  Application application;
  ApplicationHolder.acquireReadLock();
  Applications persistedApplications=ApplicationHolder.getApplications();
  if (persistedApplications != null && persistedApplications.applicationExists(applicationContext.getApplicationId())) {
    String existingKey=persistedApplications.getApplication(applicationContext.getApplicationId()).getKey();
    application=new Application(applicationContext.getApplicationId(),existingKey);
  }
 else {
    application=new Application(applicationContext.getApplicationId());
  }
  ApplicationHolder.releaseReadLock();
  application.setTenantId(applicationContext.getTenantId());
  application.setTenantDomain(applicationContext.getTenantDomain());
  application.setTenantAdminUserName(applicationContext.getTenantAdminUsername());
  Set<StartupOrder> startupOrderSet=new LinkedHashSet<StartupOrder>();
  DependencyOrder dependencyOrder=new DependencyOrder();
  dependencyOrder.setStartupOrders(startupOrderSet);
  application.setDependencyOrder(dependencyOrder);
  ComponentContext components=applicationContext.getComponents();
  if (components != null) {
    DependencyContext dependencyContext=components.getDependencyContext();
    if (dependencyContext != null) {
      String[] startupOrders=dependencyContext.getStartupOrdersContexts();
      if (startupOrders != null) {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + applicationContext.getAlias() + "String_Node_Str"+ startupOrders.length);
        }
        ParserUtils.validateStartupOrderAlias(startupOrders,applicationContext);
        dependencyOrder.setStartupOrders(ParserUtils.convertStartupOrder(startupOrders));
      }
 else {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + applicationContext.getAlias());
        }
      }
      String[] scalingDependents=dependencyContext.getScalingDependents();
      if (scalingDependents != null) {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + applicationContext.getAlias() + "String_Node_Str"+ scalingDependents.length);
        }
        dependencyOrder.setScalingDependents(ParserUtils.convertScalingDependentList(scalingDependents));
      }
 else {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + applicationContext.getAlias());
        }
      }
      String terminationBehaviour=dependencyContext.getTerminationBehaviour();
      validateTerminationBehavior(terminationBehaviour);
      dependencyOrder.setTerminationBehaviour(terminationBehaviour);
    }
    CartridgeContext[] cartridgeContexts=components.getCartridgeContexts();
    if (cartridgeContexts != null) {
      List<CartridgeContext> cartridgeContextList=Arrays.asList(cartridgeContexts);
      Set<StartupOrder> startupOrders=application.getDependencyOrder().getStartupOrders();
      Map<String,Map<String,ClusterDataHolder>> clusterDataMap;
      clusterDataMap=parseLeafLevelSubscriptions(applicationContext.getApplicationId(),applicationContext.getTenantId(),application.getKey(),null,cartridgeContextList,startupOrders);
      application.setClusterData(clusterDataMap.get(ALIAS));
      application.setClusterDataForType(clusterDataMap.get(CARTRIDGE_TYPE));
    }
    if (components.getGroupContexts() != null) {
      application.setGroups(parseGroups(applicationContext.getApplicationId(),applicationContext.getTenantId(),application.getKey(),Arrays.asList(components.getGroupContexts()),subscribableInfoCtxts));
    }
  }
  application.setAliasToDeploymentPolicyIdMap(AutoscalerUtil.getAliasToDeploymentPolicyIdMapOfApplication(applicationContext));
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + applicationContext.getApplicationId());
  }
  return application;
}