Program: 155174
Project: 155174
Buggy source:
private void recover(Iterator<List<TxLog.Record>> danglingRecordList){
  try {
    log.info("String_Node_Str");
    List<NonCompletedTransaction> commitList=new ArrayList<NonCompletedTransaction>();
    List<Xid> rollbackList=new LinkedList<Xid>();
    Map<Resource,XAResource> resourceMap=new HashMap<Resource,XAResource>();
    buildRecoveryInfo(commitList,rollbackList,resourceMap,danglingRecordList);
    Iterator<Resource> resourceItr=resourceMap.keySet().iterator();
    List<Xid> recoveredXidsList=new LinkedList<Xid>();
    while (resourceItr.hasNext()) {
      XAResource xaRes=resourceMap.get(resourceItr.next());
      Xid xids[]=xaRes.recover(XAResource.TMNOFLAGS);
      for (int i=0; i < xids.length; i++) {
        if (XidImpl.isThisTm(xids[i].getGlobalTransactionId())) {
          if (rollbackList.contains(xids[i])) {
            log.info("String_Node_Str" + xids[i] + "String_Node_Str");
            rollbackList.remove(xids[i]);
            xaRes.rollback(xids[i]);
          }
 else {
            recoveredXidsList.add(xids[i]);
          }
        }
 else {
          log.warning("String_Node_Str" + xids[i]);
        }
      }
    }
    Collections.sort(commitList,new Comparator<NonCompletedTransaction>(){
      public int compare(      NonCompletedTransaction r1,      NonCompletedTransaction r2){
        return r1.getSequenceNumber() - r2.getSequenceNumber();
      }
    }
);
    Iterator<NonCompletedTransaction> commitItr=commitList.iterator();
    while (commitItr.hasNext()) {
      NonCompletedTransaction nct=commitItr.next();
      int seq=nct.getSequenceNumber();
      Xid xids[]=nct.getXids();
      log.info("String_Node_Str" + seq + "String_Node_Str"+ xids.length);
      for (int i=0; i < xids.length; i++) {
        if (!recoveredXidsList.contains(xids[i])) {
          log.info("String_Node_Str" + seq + "String_Node_Str"+ xids[i]+ "String_Node_Str"+ "String_Node_Str");
          continue;
        }
        recoveredXidsList.remove(xids[i]);
        Resource resource=new Resource(xids[i].getBranchQualifier());
        if (!resourceMap.containsKey(resource)) {
          throw new RuntimeException("String_Node_Str" + xids[i]);
        }
        log.info("String_Node_Str" + seq + "String_Node_Str"+ xids[i]+ "String_Node_Str");
        resourceMap.get(resource).commit(xids[i],false);
      }
    }
    Iterator<Xid> rollbackItr=recoveredXidsList.iterator();
    while (rollbackItr.hasNext()) {
      Xid xid=rollbackItr.next();
      Resource resource=new Resource(xid.getBranchQualifier());
      if (!resourceMap.containsKey(resource)) {
        throw new RuntimeException("String_Node_Str" + xid);
      }
      log.info("String_Node_Str" + xid + "String_Node_Str");
      resourceMap.get(resource).rollback(xid);
    }
    if (rollbackList.size() > 0) {
      log.warning("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str" + rollbackList.size() + "String_Node_Str");
    }
  }
 catch (  XAException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
private void recover(Iterator<List<TxLog.Record>> danglingRecordList){
  try {
    List<NonCompletedTransaction> commitList=new ArrayList<NonCompletedTransaction>();
    List<Xid> rollbackList=new LinkedList<Xid>();
    Map<Resource,XAResource> resourceMap=new HashMap<Resource,XAResource>();
    buildRecoveryInfo(commitList,rollbackList,resourceMap,danglingRecordList);
    Iterator<Resource> resourceItr=resourceMap.keySet().iterator();
    List<Xid> recoveredXidsList=new LinkedList<Xid>();
    while (resourceItr.hasNext()) {
      XAResource xaRes=resourceMap.get(resourceItr.next());
      Xid xids[]=xaRes.recover(XAResource.TMNOFLAGS);
      for (int i=0; i < xids.length; i++) {
        if (XidImpl.isThisTm(xids[i].getGlobalTransactionId())) {
          if (rollbackList.contains(xids[i])) {
            log.fine("String_Node_Str" + xids[i] + "String_Node_Str");
            rollbackList.remove(xids[i]);
            xaRes.rollback(xids[i]);
          }
 else {
            recoveredXidsList.add(xids[i]);
          }
        }
 else {
          log.warning("String_Node_Str" + xids[i]);
        }
      }
    }
    Collections.sort(commitList,new Comparator<NonCompletedTransaction>(){
      public int compare(      NonCompletedTransaction r1,      NonCompletedTransaction r2){
        return r1.getSequenceNumber() - r2.getSequenceNumber();
      }
    }
);
    Iterator<NonCompletedTransaction> commitItr=commitList.iterator();
    while (commitItr.hasNext()) {
      NonCompletedTransaction nct=commitItr.next();
      int seq=nct.getSequenceNumber();
      Xid xids[]=nct.getXids();
      log.fine("String_Node_Str" + seq + "String_Node_Str"+ xids.length);
      for (int i=0; i < xids.length; i++) {
        if (!recoveredXidsList.contains(xids[i])) {
          log.fine("String_Node_Str" + seq + "String_Node_Str"+ xids[i]+ "String_Node_Str"+ "String_Node_Str");
          continue;
        }
        recoveredXidsList.remove(xids[i]);
        Resource resource=new Resource(xids[i].getBranchQualifier());
        if (!resourceMap.containsKey(resource)) {
          throw new RuntimeException("String_Node_Str" + xids[i]);
        }
        log.fine("String_Node_Str" + seq + "String_Node_Str"+ xids[i]+ "String_Node_Str");
        resourceMap.get(resource).commit(xids[i],false);
      }
    }
    Iterator<Xid> rollbackItr=recoveredXidsList.iterator();
    while (rollbackItr.hasNext()) {
      Xid xid=rollbackItr.next();
      Resource resource=new Resource(xid.getBranchQualifier());
      if (!resourceMap.containsKey(resource)) {
        throw new RuntimeException("String_Node_Str" + xid);
      }
      log.fine("String_Node_Str" + xid + "String_Node_Str");
      resourceMap.get(resource).rollback(xid);
    }
    if (rollbackList.size() > 0) {
      log.fine("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str" + rollbackList.size() + "String_Node_Str");
    }
  }
 catch (  XAException e) {
    throw new RuntimeException(e);
  }
}