Program: 24724
Project: 24724
Buggy source:
/** 
 * Get a list of all elements with a given name. This is implemented as a memo function: the first time it is called for a particular element type, it remembers the result for next time.
 */
protected AxisIterator getAllElements(int fingerprint){
  String subName="String_Node_Str" + namePool.getDisplayName(fingerprint);
  try {
    SubStoreReader indexFile=mainStore.openSubStore(subName);
    PackedByteBuf buf=new PackedByteBuf(indexFile,(int)indexFile.length());
    int nNodes=buf.readInt();
    ArrayList nodes=new ArrayList(nNodes);
    int curNodeNum=0;
    for (int i=0; i < nNodes; i++) {
      curNodeNum+=buf.readInt();
      nodes.add(getNode(curNodeNum));
    }
    indexFile.close();
    return new NodeListIterator(nodes);
  }
 catch (  IOException e) {
  }
  if (debug) {
    Trace.debug("String_Node_Str" + namePool.getDisplayName(fingerprint) + "String_Node_Str");
  }
  ArrayList nodes=new ArrayList(numberOfNodes / 8);
  Vector nodeNums=new Vector(numberOfNodes / 8);
  for (int i=0; i < numberOfNodes; i++) {
    NodeImpl node=getNode(i);
    if (node == null || (node.getNameCode() & 0xfffff) != fingerprint)     continue;
    nodes.add(node);
    nodeNums.add(Integer.valueOf(node.nodeNum));
  }
  PackedByteBuf buf=new PackedByteBuf(nodeNums.size() * 3);
  buf.writeInt(nodeNums.size());
  int curNum=0;
  for (int i=0; i < nodeNums.size(); i++) {
    int num=((Integer)nodeNums.get(i)).intValue();
    buf.writeInt(num - curNum);
    curNum=num;
  }
  try {
    SubStoreWriter indexFile=mainStore.createSubStore(subName);
    buf.output(indexFile);
    indexFile.close();
  }
 catch (  IOException e) {
  }
  if (debug)   Trace.debug("String_Node_Str");
  return new NodeListIterator(nodes);
}

Fixed version (ground truth):
/** 
 * Get a list of all elements with a given name. This is implemented as a memo function: the first time it is called for a particular element type, it remembers the result for next time.
 */
protected AxisIterator getAllElements(int fingerprint){
synchronized (mainStore) {
    String subName="String_Node_Str" + namePool.getDisplayName(fingerprint);
    try {
      SubStoreReader indexFile=mainStore.openSubStore(subName);
      PackedByteBuf buf=new PackedByteBuf(indexFile,(int)indexFile.length());
      int nNodes=buf.readInt();
      ArrayList nodes=new ArrayList(nNodes);
      int curNodeNum=0;
      for (int i=0; i < nNodes; i++) {
        curNodeNum+=buf.readInt();
        nodes.add(getNode(curNodeNum));
      }
      indexFile.close();
      return new NodeListIterator(nodes);
    }
 catch (    IOException e) {
    }
    if (debug) {
      Trace.debug("String_Node_Str" + namePool.getDisplayName(fingerprint) + "String_Node_Str");
    }
    ArrayList nodes=new ArrayList(numberOfNodes / 8);
    Vector nodeNums=new Vector(numberOfNodes / 8);
    for (int i=0; i < numberOfNodes; i++) {
      NodeImpl node=getNode(i);
      if (node == null || (node.getNameCode() & 0xfffff) != fingerprint)       continue;
      nodes.add(node);
      nodeNums.add(Integer.valueOf(node.nodeNum));
    }
    PackedByteBuf buf=new PackedByteBuf(nodeNums.size() * 3);
    buf.writeInt(nodeNums.size());
    int curNum=0;
    for (int i=0; i < nodeNums.size(); i++) {
      int num=((Integer)nodeNums.get(i)).intValue();
      buf.writeInt(num - curNum);
      curNum=num;
    }
    try {
      SubStoreWriter indexFile=mainStore.createSubStore(subName);
      buf.output(indexFile);
      indexFile.close();
    }
 catch (    IOException e) {
    }
    return new NodeListIterator(nodes);
  }
}