Program: 80229
Project: 80229
Buggy source:
public void resolve() throws BadConfigException, IOException, BadClusterStateException {
  ConfTreeOperations appConf=instanceDescription.getAppConfOperations();
  ConfTreeOperations resources=instanceDescription.getResourceOperations();
  for (  Entry<String,Map<String,String>> entry : resources.getComponents().entrySet()) {
    if (COMPONENT_AM.equals(entry.getKey())) {
      continue;
    }
    if (entry.getValue().containsKey(ResourceKeys.COMPONENT_PRIORITY)) {
      priorities.add(Integer.parseInt(entry.getValue().get(ResourceKeys.COMPONENT_PRIORITY)));
    }
  }
  Set<String> externalComponents=getExternalComponents(appConf);
  if (!externalComponents.isEmpty()) {
    log.info("String_Node_Str",externalComponents);
  }
  for (  String component : externalComponents) {
    if (!isClusternameValid(component)) {
      throw new BadConfigException(component + "String_Node_Str" + "String_Node_Str");
    }
    Path componentClusterDir=coreFS.buildClusterDirPath(component);
    try {
      coreFS.verifyPathExists(componentClusterDir);
    }
 catch (    IOException e) {
      throw new BadConfigException("String_Node_Str" + component + "String_Node_Str");
    }
    AggregateConf componentConf=new AggregateConf();
    ConfPersister persister=new ConfPersister(coreFS,componentClusterDir);
    try {
      persister.load(componentConf);
    }
 catch (    Exception e) {
      throw new BadConfigException("String_Node_Str" + "String_Node_Str" + component);
    }
    ConfTreeOperations componentAppConf=componentConf.getAppConfOperations();
    String externalAppDef=componentAppConf.get(AgentKeys.APP_DEF);
    if (SliderUtils.isSet(externalAppDef)) {
      Path newAppDef=new Path(coreFS.buildAppDefDirPath(clustername),component + "String_Node_Str" + SliderKeys.DEFAULT_APP_PKG);
      componentAppConf.set(AgentKeys.APP_DEF,newAppDef);
      componentAppConf.append(AgentKeys.APP_DEF_ORIGINAL,externalAppDef);
      log.info("String_Node_Str",externalAppDef,newAppDef,component);
      externalAppDefs.put(externalAppDef,newAppDef);
      externalAppDef=newAppDef.toString();
    }
    for (    String rcomp : componentConf.getResourceOperations().getComponentNames()) {
      if (COMPONENT_AM.equals(rcomp)) {
        continue;
      }
      log.debug("String_Node_Str",rcomp,component);
      componentAppConf.getOrAddComponent(rcomp);
    }
    componentConf.resolve();
    for (    String rcomp : componentConf.getResourceOperations().getComponentNames()) {
      if (COMPONENT_AM.equals(rcomp)) {
        continue;
      }
      String componentAppDef=componentAppConf.getComponentOpt(rcomp,AgentKeys.APP_DEF,null);
      if (SliderUtils.isUnset(componentAppDef) || componentAppDef.equals(externalAppDef)) {
        continue;
      }
      if (externalAppDefs.containsKey(componentAppDef)) {
        log.info("String_Node_Str",externalAppDefs.get(componentAppDef),rcomp);
      }
 else {
        String existingPrefix=componentAppConf.getComponentOpt(rcomp,ROLE_PREFIX,null);
        if (SliderUtils.isUnset(existingPrefix)) {
          existingPrefix="String_Node_Str";
        }
 else {
          existingPrefix=COMPONENT_SEPARATOR + SliderUtils.trimPrefix(existingPrefix);
        }
        Path newAppDef=new Path(coreFS.buildAppDefDirPath(clustername),component + existingPrefix + "String_Node_Str"+ SliderKeys.DEFAULT_APP_PKG);
        externalAppDefs.put(componentAppDef,newAppDef);
        log.info("String_Node_Str",componentAppDef,newAppDef,component + COMPONENT_SEPARATOR + rcomp);
      }
      componentAppConf.setComponentOpt(rcomp,AgentKeys.APP_DEF,externalAppDefs.get(componentAppDef).toString());
      componentAppConf.appendComponentOpt(rcomp,AgentKeys.APP_DEF_ORIGINAL,componentAppDef);
    }
    Set<Path> newAppDefs=new HashSet<>();
    newAppDefs.addAll(externalAppDefs.values());
    if (newAppDefs.size() != externalAppDefs.size()) {
      throw new IllegalStateException("String_Node_Str" + externalAppDefs);
    }
    log.info("String_Node_Str",component,externalAppDefs);
    mergeExternalComponent(appConf,componentAppConf,component,null);
    mergeExternalComponent(resources,componentConf.getResourceOperations(),component,getNextPriority());
  }
}

Fixed version (ground truth):
public void resolve() throws BadConfigException, IOException, BadClusterStateException {
  ConfTreeOperations appConf=instanceDescription.getAppConfOperations();
  ConfTreeOperations resources=instanceDescription.getResourceOperations();
  for (  Entry<String,Map<String,String>> entry : resources.getComponents().entrySet()) {
    if (COMPONENT_AM.equals(entry.getKey())) {
      continue;
    }
    if (entry.getValue().containsKey(ResourceKeys.COMPONENT_PRIORITY)) {
      priorities.add(Integer.parseInt(entry.getValue().get(ResourceKeys.COMPONENT_PRIORITY)));
    }
  }
  Set<String> externalComponents=getExternalComponents(appConf);
  if (!externalComponents.isEmpty()) {
    log.info("String_Node_Str",externalComponents);
  }
  for (  String component : externalComponents) {
    if (!isClusternameValid(component)) {
      throw new BadConfigException(component + "String_Node_Str" + "String_Node_Str");
    }
    Path componentClusterDir=coreFS.buildClusterDirPath(component);
    try {
      coreFS.verifyPathExists(componentClusterDir);
    }
 catch (    IOException e) {
      throw new BadConfigException("String_Node_Str" + component + "String_Node_Str");
    }
    AggregateConf componentConf=new AggregateConf();
    ConfPersister persister=new ConfPersister(coreFS,componentClusterDir);
    try {
      persister.load(componentConf);
    }
 catch (    Exception e) {
      throw new BadConfigException("String_Node_Str" + "String_Node_Str" + component);
    }
    ConfTreeOperations componentAppConf=componentConf.getAppConfOperations();
    String externalAppDef=componentAppConf.get(AgentKeys.APP_DEF);
    if (SliderUtils.isSet(externalAppDef)) {
      Path newAppDef=new Path(coreFS.buildAppDefDirPath(clustername),component + "String_Node_Str" + SliderKeys.DEFAULT_APP_PKG);
      componentAppConf.set(AgentKeys.APP_DEF,newAppDef);
      componentAppConf.append(AgentKeys.APP_DEF_ORIGINAL,externalAppDef);
      log.info("String_Node_Str",externalAppDef,newAppDef,component);
      externalAppDefs.put(externalAppDef,newAppDef);
      externalAppDef=newAppDef.toString();
    }
    for (    String rcomp : componentConf.getResourceOperations().getComponentNames()) {
      if (COMPONENT_AM.equals(rcomp)) {
        continue;
      }
      log.debug("String_Node_Str",rcomp,component);
      componentAppConf.getOrAddComponent(rcomp);
    }
    componentConf.resolve();
    for (    String rcomp : componentConf.getResourceOperations().getComponentNames()) {
      if (COMPONENT_AM.equals(rcomp)) {
        continue;
      }
      String componentAppDef=componentAppConf.getComponentOpt(rcomp,AgentKeys.APP_DEF,null);
      if (SliderUtils.isUnset(componentAppDef) || componentAppDef.equals(externalAppDef)) {
        continue;
      }
      if (externalAppDefs.containsKey(componentAppDef)) {
        log.info("String_Node_Str",externalAppDefs.get(componentAppDef),rcomp);
      }
 else {
        String existingPrefix=componentAppConf.getComponentOpt(rcomp,ROLE_PREFIX,null);
        if (SliderUtils.isUnset(existingPrefix)) {
          existingPrefix="String_Node_Str";
        }
 else {
          existingPrefix=COMPONENT_SEPARATOR + SliderUtils.trimPrefix(existingPrefix);
        }
        Path newAppDef=new Path(coreFS.buildAppDefDirPath(clustername),component + existingPrefix + "String_Node_Str"+ SliderKeys.DEFAULT_APP_PKG);
        externalAppDefs.put(componentAppDef,newAppDef);
        log.info("String_Node_Str",componentAppDef,newAppDef,component + COMPONENT_SEPARATOR + rcomp);
      }
      componentAppConf.setComponentOpt(rcomp,AgentKeys.APP_DEF,externalAppDefs.get(componentAppDef).toString());
      componentAppConf.appendComponentOpt(rcomp,AgentKeys.APP_DEF_ORIGINAL,componentAppDef);
    }
    Set<Path> newAppDefs=new HashSet<>();
    newAppDefs.addAll(externalAppDefs.values());
    if (newAppDefs.size() != externalAppDefs.size()) {
      throw new IllegalStateException("String_Node_Str" + externalAppDefs);
    }
    log.info("String_Node_Str",component,externalAppDefs);
    SliderUtils.mergeMapsIgnoreDuplicateKeys(appConf.getConfTree().credentials,componentAppConf.getConfTree().credentials);
    mergeExternalComponent(appConf,componentAppConf,component,null);
    mergeExternalComponent(resources,componentConf.getResourceOperations(),component,getNextPriority());
  }
}