Program: 12079
Project: 12079
Buggy source:
private List<MappingState> matchBasedOnCodeFragments(MappingState parent,Set<PDGNode> nodesG1,Set<PDGNode> nodesG2){
  CodeFragmentDecomposer cfd1=new CodeFragmentDecomposer(nodesG1);
  CodeFragmentDecomposer cfd2=new CodeFragmentDecomposer(nodesG2);
  Map<PlainVariable,Set<PDGNode>> map1=cfd1.getObjectNodeMap();
  Map<PlainVariable,Set<PDGNode>> map2=cfd2.getObjectNodeMap();
  if (map1.isEmpty() || map2.isEmpty()) {
    return processPDGNodes(parent,nodesG1,nodesG2);
  }
 else {
    MappingState finalState=parent;
    for (    PlainVariable variable1 : map1.keySet()) {
      Set<PDGNode> variableNodesG1=map1.get(variable1);
      Set<PDGNode> tempNodesG1=new LinkedHashSet<PDGNode>(variableNodesG1);
      Map<PlainVariable,List<MappingState>> currentStateMap=new LinkedHashMap<PlainVariable,List<MappingState>>();
      for (      PlainVariable variable2 : map2.keySet()) {
        Set<PDGNode> variableNodesG2=map2.get(variable2);
        Set<PDGNode> tempNodesG2=new LinkedHashSet<PDGNode>(variableNodesG2);
        if (finalState != null) {
          for (          PDGNodeMapping mapping : finalState.getNodeMappings()) {
            if (tempNodesG1.contains(mapping.getNodeG1()))             tempNodesG1.remove(mapping.getNodeG1());
            if (tempNodesG2.contains(mapping.getNodeG2()))             tempNodesG2.remove(mapping.getNodeG2());
          }
        }
        List<MappingState> maxStates=processPDGNodes(finalState,tempNodesG1,tempNodesG2);
        currentStateMap.put(variable2,maxStates);
      }
      List<MappingState> currentStates=new ArrayList<MappingState>();
      for (      PlainVariable variable2 : currentStateMap.keySet()) {
        currentStates.addAll(currentStateMap.get(variable2));
      }
      if (!currentStates.isEmpty()) {
        MappingState best=findMaximumStateWithMinimumDifferences(currentStates);
        PlainVariable variableToRemove=null;
        for (        PlainVariable variable2 : currentStateMap.keySet()) {
          if (currentStateMap.get(variable2).contains(best)) {
            variableToRemove=variable2;
            break;
          }
        }
        map2.remove(variableToRemove);
        finalState=best;
      }
    }
    List<MappingState> currentStates=new ArrayList<MappingState>();
    Set<PDGNode> tempNodesG1=new LinkedHashSet<PDGNode>(nodesG1);
    Set<PDGNode> tempNodesG2=new LinkedHashSet<PDGNode>(nodesG2);
    for (    PDGNodeMapping mapping : finalState.getNodeMappings()) {
      if (tempNodesG1.contains(mapping.getNodeG1()))       tempNodesG1.remove(mapping.getNodeG1());
      if (tempNodesG2.contains(mapping.getNodeG2()))       tempNodesG2.remove(mapping.getNodeG2());
    }
    if (tempNodesG1.isEmpty() || tempNodesG2.isEmpty()) {
      currentStates.add(finalState);
    }
 else {
      List<MappingState> maxStates=processPDGNodes(finalState,tempNodesG1,tempNodesG2);
      for (      MappingState temp : maxStates) {
        if (!currentStates.contains(temp)) {
          currentStates.add(temp);
        }
      }
    }
    return currentStates;
  }
}

Fixed version (ground truth):
private List<MappingState> matchBasedOnCodeFragments(MappingState parent,Set<PDGNode> nodesG1,Set<PDGNode> nodesG2){
  CodeFragmentDecomposer cfd1=new CodeFragmentDecomposer(nodesG1,pdg1.getFieldsAccessedInMethod());
  CodeFragmentDecomposer cfd2=new CodeFragmentDecomposer(nodesG2,pdg2.getFieldsAccessedInMethod());
  Map<PlainVariable,Set<PDGNode>> map1=cfd1.getObjectNodeMap();
  Map<PlainVariable,Set<PDGNode>> map2=cfd2.getObjectNodeMap();
  if (map1.isEmpty() || map2.isEmpty()) {
    return processPDGNodes(parent,nodesG1,nodesG2);
  }
 else {
    MappingState finalState=parent;
    for (    PlainVariable variable1 : map1.keySet()) {
      Set<PDGNode> variableNodesG1=map1.get(variable1);
      Set<PDGNode> tempNodesG1=new LinkedHashSet<PDGNode>(variableNodesG1);
      Map<PlainVariable,List<MappingState>> currentStateMap=new LinkedHashMap<PlainVariable,List<MappingState>>();
      for (      PlainVariable variable2 : map2.keySet()) {
        Set<PDGNode> variableNodesG2=map2.get(variable2);
        Set<PDGNode> tempNodesG2=new LinkedHashSet<PDGNode>(variableNodesG2);
        if (finalState != null) {
          for (          PDGNodeMapping mapping : finalState.getNodeMappings()) {
            if (tempNodesG1.contains(mapping.getNodeG1()))             tempNodesG1.remove(mapping.getNodeG1());
            if (tempNodesG2.contains(mapping.getNodeG2()))             tempNodesG2.remove(mapping.getNodeG2());
          }
        }
        List<MappingState> maxStates=processPDGNodes(finalState,tempNodesG1,tempNodesG2);
        currentStateMap.put(variable2,maxStates);
      }
      List<MappingState> currentStates=new ArrayList<MappingState>();
      for (      PlainVariable variable2 : currentStateMap.keySet()) {
        currentStates.addAll(currentStateMap.get(variable2));
      }
      if (!currentStates.isEmpty()) {
        MappingState best=findMaximumStateWithMinimumDifferences(currentStates);
        PlainVariable variableToRemove=null;
        for (        PlainVariable variable2 : currentStateMap.keySet()) {
          if (currentStateMap.get(variable2).contains(best)) {
            variableToRemove=variable2;
            break;
          }
        }
        map2.remove(variableToRemove);
        finalState=best;
      }
    }
    List<MappingState> currentStates=new ArrayList<MappingState>();
    Set<PDGNode> tempNodesG1=new LinkedHashSet<PDGNode>(nodesG1);
    Set<PDGNode> tempNodesG2=new LinkedHashSet<PDGNode>(nodesG2);
    for (    PDGNodeMapping mapping : finalState.getNodeMappings()) {
      if (tempNodesG1.contains(mapping.getNodeG1()))       tempNodesG1.remove(mapping.getNodeG1());
      if (tempNodesG2.contains(mapping.getNodeG2()))       tempNodesG2.remove(mapping.getNodeG2());
    }
    if (tempNodesG1.isEmpty() || tempNodesG2.isEmpty()) {
      currentStates.add(finalState);
    }
 else {
      List<MappingState> maxStates=processPDGNodes(finalState,tempNodesG1,tempNodesG2);
      for (      MappingState temp : maxStates) {
        if (!currentStates.contains(temp)) {
          currentStates.add(temp);
        }
      }
    }
    return currentStates;
  }
}