Program: 115569
Project: 115569
Buggy source:
/** 
 * Parse Subscription Information
 * @param appId                Application id
 * @param tenantId             Tenant id of tenant which deployed the Application
 * @param key                  Generated key for the Application
 * @param groupName            Group name (if relevant)
 * @param cartridgeContextList cartridgeContextList
 * @return Map [subscription alias -> ClusterDataHolder]
 * @throws ApplicationDefinitionException
 */
private Map<String,Map<String,ClusterDataHolder>> parseLeafLevelSubscriptions(String appId,int tenantId,String key,String groupName,List<CartridgeContext> cartridgeContextList,Set<StartupOrder> dependencyOrder) throws ApplicationDefinitionException, CartridgeNotFoundException {
  Map<String,Map<String,ClusterDataHolder>> completeDataHolder=new HashMap<String,Map<String,ClusterDataHolder>>();
  Map<String,ClusterDataHolder> clusterDataMap=new HashMap<String,ClusterDataHolder>();
  Map<String,ClusterDataHolder> clusterDataMapByType=new HashMap<String,ClusterDataHolder>();
  createClusterDataMap(appId,cartridgeContextList,clusterDataMap,clusterDataMapByType,tenantId);
  for (  CartridgeContext cartridgeContext : cartridgeContextList) {
    List<String> dependencyClusterIDs=new ArrayList<String>();
    List<String> exportMetadataKeys=new ArrayList<String>();
    List<String> importMetadataKeys=new ArrayList<String>();
    String cartridgeType=cartridgeContext.getType();
    SubscribableInfoContext subscribableInfoContext=cartridgeContext.getSubscribableInfoContext();
    String subscriptionAlias=subscribableInfoContext.getAlias();
    Cartridge cartridge=getCartridgeByTenant(cartridgeType,tenantId);
    if (cartridge == null) {
      throw new CartridgeNotFoundException(String.format("String_Node_Str" + "String_Node_Str",cartridgeContext.getUuid(),cartridgeType));
    }
    String[] metadataKeys=cartridge.getMetadataKeys();
    if (metadataKeys != null) {
      for (      String str : metadataKeys) {
        if (!StringUtils.isBlank(str)) {
          exportMetadataKeys.add(cartridgeContext.getSubscribableInfoContext().getAlias() + METADATA_APPENDER + str);
        }
      }
    }
    ClusterInformation clusterInfo;
    if (cartridge.getMultiTenant()) {
      clusterInfo=new MTClusterInformation();
    }
 else {
      clusterInfo=new STClusterInformation();
    }
    String hostname=clusterInfo.getHostName(appId,subscriptionAlias,cartridge.getHostName());
    String clusterId=clusterInfo.getClusterId(appId,subscriptionAlias,cartridgeType);
    String repoUrl=null;
    if (subscribableInfoContext.getArtifactRepositoryContext() != null) {
      repoUrl=subscribableInfoContext.getArtifactRepositoryContext().getRepoUrl();
    }
    if (dependencyOrder != null) {
      for (      StartupOrder startupOrder : dependencyOrder) {
        for (        String startupOrderComponent : startupOrder.getStartupOrderComponentList()) {
          String[] arrStartUp=startupOrderComponent.split("String_Node_Str");
          if (arrStartUp[0].equals("String_Node_Str")) {
            String cartridgeAlias=arrStartUp[1];
            String dependentCartridgeType=findCartridgeTypeFromAlias(cartridgeContextList,cartridgeAlias);
            if (StringUtils.isBlank(dependentCartridgeType)) {
              throw new CartridgeNotFoundException(String.format("String_Node_Str" + "String_Node_Str",appId,cartridgeAlias));
            }
            Cartridge dependencyCartridge=getCartridgeByTenant(dependentCartridgeType,tenantId);
            ClusterDataHolder dataHolder=clusterDataMapByType.get(dependentCartridgeType);
            if (dataHolder != null) {
              if (!dataHolder.getClusterId().equals(clusterId)) {
                dependencyClusterIDs.add(dataHolder.getClusterId());
                if (dependencyCartridge.getMetadataKeys() != null) {
                  for (                  String str : dependencyCartridge.getMetadataKeys()) {
                    if (!StringUtils.isBlank(str)) {
                      importMetadataKeys.add(dataHolder.getClusterId().split("String_Node_Str")[0] + METADATA_APPENDER + str);
                    }
                  }
                }
                if (!dataHolder.getClusterId().equals(clusterId)) {
                  if (startupOrderComponent.equals("String_Node_Str".concat(cartridgeType))) {
                    break;
                  }
                }
              }
            }
          }
        }
      }
    }
    String[] arrDependencyClusterIDs=new String[dependencyClusterIDs.size()];
    arrDependencyClusterIDs=dependencyClusterIDs.toArray(arrDependencyClusterIDs);
    String[] arrExportMetadata=new String[exportMetadataKeys.size()];
    arrExportMetadata=exportMetadataKeys.toArray(arrExportMetadata);
    String[] arrImportMetadata=new String[importMetadataKeys.size()];
    arrImportMetadata=importMetadataKeys.toArray(arrImportMetadata);
    String tenantRange=AutoscalerUtil.findTenantRange(tenantId,cartridge.getTenantPartitions());
    Boolean isLB=false;
    if (cartridge.getCategory().equals(LOAD_BALANCER)) {
      isLB=true;
    }
    ApplicationClusterContext appClusterCtxt=createApplicationClusterContext(appId,groupName,cartridge,key,tenantId,repoUrl,subscriptionAlias,clusterId,hostname,subscribableInfoContext.getDeploymentPolicyUuid(),isLB,tenantRange,subscribableInfoContext.getDependencyAliases(),subscribableInfoContext.getProperties(),arrDependencyClusterIDs,arrExportMetadata,arrImportMetadata);
    appClusterCtxt.setAutoscalePolicyName(subscribableInfoContext.getAutoscalingPolicyUuid());
    appClusterCtxt.setProperties(subscribableInfoContext.getProperties());
    if (subscribableInfoContext.getPersistenceContext() != null) {
      appClusterCtxt.setPersistenceContext(subscribableInfoContext.getPersistenceContext());
    }
    this.applicationClusterContexts.add(appClusterCtxt);
  }
  completeDataHolder.put(CARTRIDGE_TYPE,clusterDataMapByType);
  completeDataHolder.put(ALIAS,clusterDataMap);
  return completeDataHolder;
}

Fixed version (ground truth):
/** 
 * Parse Subscription Information
 * @param appId                Application id
 * @param tenantId             Tenant id of tenant which deployed the Application
 * @param key                  Generated key for the Application
 * @param groupName            Group name (if relevant)
 * @param cartridgeContextList cartridgeContextList
 * @return Map [subscription alias -> ClusterDataHolder]
 * @throws ApplicationDefinitionException
 */
private Map<String,Map<String,ClusterDataHolder>> parseLeafLevelSubscriptions(String appId,int tenantId,String key,String groupName,List<CartridgeContext> cartridgeContextList,Set<StartupOrder> dependencyOrder) throws ApplicationDefinitionException, CartridgeNotFoundException {
  Map<String,Map<String,ClusterDataHolder>> completeDataHolder=new HashMap<String,Map<String,ClusterDataHolder>>();
  Map<String,ClusterDataHolder> clusterDataMap=new HashMap<String,ClusterDataHolder>();
  Map<String,ClusterDataHolder> clusterDataMapByType=new HashMap<String,ClusterDataHolder>();
  createClusterDataMap(appId,cartridgeContextList,clusterDataMap,clusterDataMapByType,tenantId);
  for (  CartridgeContext cartridgeContext : cartridgeContextList) {
    List<String> dependencyClusterIDs=new ArrayList<String>();
    List<String> exportMetadataKeys=new ArrayList<String>();
    List<String> importMetadataKeys=new ArrayList<String>();
    String cartridgeType=cartridgeContext.getType();
    SubscribableInfoContext subscribableInfoContext=cartridgeContext.getSubscribableInfoContext();
    String subscriptionAlias=subscribableInfoContext.getAlias();
    Cartridge cartridge=getCartridgeByTenant(cartridgeType,tenantId);
    if (cartridge == null) {
      throw new CartridgeNotFoundException(String.format("String_Node_Str" + "String_Node_Str",cartridgeContext.getUuid(),cartridgeType));
    }
    String[] metadataKeys=cartridge.getMetadataKeys();
    if (metadataKeys != null) {
      for (      String str : metadataKeys) {
        if (!StringUtils.isBlank(str)) {
          exportMetadataKeys.add(cartridgeContext.getSubscribableInfoContext().getAlias() + METADATA_APPENDER + str);
        }
      }
    }
    ClusterInformation clusterInfo;
    if (cartridge.getMultiTenant()) {
      clusterInfo=new MTClusterInformation();
    }
 else {
      clusterInfo=new STClusterInformation();
    }
    String hostname=clusterInfo.getHostName(appId,subscriptionAlias,cartridge.getHostName());
    String clusterId=clusterInfo.getClusterId(appId,subscriptionAlias,cartridgeType);
    String repoUrl=null;
    if (subscribableInfoContext.getArtifactRepositoryContext() != null) {
      repoUrl=subscribableInfoContext.getArtifactRepositoryContext().getRepoUrl();
    }
    if (dependencyOrder != null) {
      for (      StartupOrder startupOrder : dependencyOrder) {
        for (        String startupOrderComponent : startupOrder.getStartupOrderComponentList()) {
          String[] arrStartUp=startupOrderComponent.split("String_Node_Str");
          if (arrStartUp[0].equals("String_Node_Str")) {
            String cartridgeAlias=arrStartUp[1];
            String dependentCartridgeUuid=getCartridgeUuid(cartridgeContextList,cartridgeAlias);
            if (StringUtils.isBlank(dependentCartridgeUuid)) {
              throw new CartridgeNotFoundException(String.format("String_Node_Str" + "String_Node_Str",appId,cartridgeAlias));
            }
            Cartridge dependencyCartridge=getCartridge(dependentCartridgeUuid);
            ClusterDataHolder dataHolder=clusterDataMapByType.get(dependentCartridgeUuid);
            if (dataHolder != null) {
              if (!dataHolder.getClusterId().equals(clusterId)) {
                dependencyClusterIDs.add(dataHolder.getClusterId());
                if (dependencyCartridge.getMetadataKeys() != null) {
                  for (                  String str : dependencyCartridge.getMetadataKeys()) {
                    if (!StringUtils.isBlank(str)) {
                      importMetadataKeys.add(dataHolder.getClusterId().split("String_Node_Str")[0] + METADATA_APPENDER + str);
                    }
                  }
                }
                if (!dataHolder.getClusterId().equals(clusterId)) {
                  if (startupOrderComponent.equals("String_Node_Str".concat(cartridgeType))) {
                    break;
                  }
                }
              }
            }
          }
        }
      }
    }
    String[] arrDependencyClusterIDs=new String[dependencyClusterIDs.size()];
    arrDependencyClusterIDs=dependencyClusterIDs.toArray(arrDependencyClusterIDs);
    String[] arrExportMetadata=new String[exportMetadataKeys.size()];
    arrExportMetadata=exportMetadataKeys.toArray(arrExportMetadata);
    String[] arrImportMetadata=new String[importMetadataKeys.size()];
    arrImportMetadata=importMetadataKeys.toArray(arrImportMetadata);
    String tenantRange=AutoscalerUtil.findTenantRange(tenantId,cartridge.getTenantPartitions());
    Boolean isLB=false;
    if (cartridge.getCategory().equals(LOAD_BALANCER)) {
      isLB=true;
    }
    ApplicationClusterContext appClusterCtxt=createApplicationClusterContext(appId,groupName,cartridge,key,tenantId,repoUrl,subscriptionAlias,clusterId,hostname,subscribableInfoContext.getDeploymentPolicyUuid(),isLB,tenantRange,subscribableInfoContext.getDependencyAliases(),subscribableInfoContext.getProperties(),arrDependencyClusterIDs,arrExportMetadata,arrImportMetadata);
    appClusterCtxt.setAutoscalePolicyName(subscribableInfoContext.getAutoscalingPolicyUuid());
    appClusterCtxt.setProperties(subscribableInfoContext.getProperties());
    if (subscribableInfoContext.getPersistenceContext() != null) {
      appClusterCtxt.setPersistenceContext(subscribableInfoContext.getPersistenceContext());
    }
    this.applicationClusterContexts.add(appClusterCtxt);
  }
  completeDataHolder.put(CARTRIDGE_TYPE,clusterDataMapByType);
  completeDataHolder.put(ALIAS,clusterDataMap);
  return completeDataHolder;
}