Program: 52484
Project: 52484
Buggy source:
/** 
 * Index the given item
 * @param item  the item to index
 * @throws BrowseException
 */
private void indexItem(ItemMetadataProxy item) throws BrowseException {
  Map<String,String> itemMDMap=new HashMap<String,String>();
  try {
    removeIndex(item.getID(),BrowseIndex.getItemBrowseIndex().getTableName());
    removeIndex(item.getID(),BrowseIndex.getWithdrawnBrowseIndex().getTableName());
    if (item.isArchived() && !item.isWithdrawn()) {
      Map<Integer,String> sortMap=getSortValues(item,itemMDMap);
      dao.insertIndex(BrowseIndex.getItemBrowseIndex().getTableName(),item.getID(),sortMap);
    }
 else     if (item.isWithdrawn()) {
      Map<Integer,String> sortMap=getSortValues(item,itemMDMap);
      dao.insertIndex(BrowseIndex.getWithdrawnBrowseIndex().getTableName(),item.getID(),sortMap);
    }
    for (int i=0; i < bis.length; i++) {
      log.debug("String_Node_Str" + item.getID() + "String_Node_Str"+ bis[i].getTableName());
      if (bis[i].isMetadataIndex()) {
        removeIndex(item.getID(),bis[i]);
        if (item.isArchived() && !item.isWithdrawn()) {
          String[] md=bis[i].getMdBits();
          DCValue[] values=item.getMetadata(md[0],md[1],md[2],Item.ANY);
          if (values != null) {
            for (int x=0; x < values.length; x++) {
              String nVal=BrowseOrder.makeSortString(values[x].value,values[x].language,bis[i].getDataType());
              Map sortMap=getSortValues(item,itemMDMap);
              dao.insertIndex(bis[i].getTableName(),item.getID(),values[x].value,nVal,sortMap);
              if (bis[i].isMetadataIndex()) {
                int distinctID=dao.getDistinctID(bis[i].getTableName(true,false,false),values[x].value,nVal);
                dao.createDistinctMapping(bis[i].getMapName(),item.getID(),distinctID);
              }
            }
          }
        }
      }
    }
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    throw new BrowseException(e);
  }
}

Fixed version (ground truth):
/** 
 * Index the given item
 * @param item  the item to index
 * @throws BrowseException
 */
private void indexItem(ItemMetadataProxy item) throws BrowseException {
  Map<String,String> itemMDMap=new HashMap<String,String>();
  try {
    removeIndex(item.getID(),BrowseIndex.getItemBrowseIndex().getTableName());
    removeIndex(item.getID(),BrowseIndex.getWithdrawnBrowseIndex().getTableName());
    dao.deleteCommunityMappings(item.getID());
    if (item.isArchived() && !item.isWithdrawn()) {
      Map<Integer,String> sortMap=getSortValues(item,itemMDMap);
      dao.insertIndex(BrowseIndex.getItemBrowseIndex().getTableName(),item.getID(),sortMap);
      dao.insertCommunityMappings(item.getID());
    }
 else     if (item.isWithdrawn()) {
      Map<Integer,String> sortMap=getSortValues(item,itemMDMap);
      dao.insertIndex(BrowseIndex.getWithdrawnBrowseIndex().getTableName(),item.getID(),sortMap);
    }
    for (int i=0; i < bis.length; i++) {
      log.debug("String_Node_Str" + item.getID() + "String_Node_Str"+ bis[i].getTableName());
      if (bis[i].isMetadataIndex()) {
        removeIndex(item.getID(),bis[i]);
        if (item.isArchived() && !item.isWithdrawn()) {
          String[] md=bis[i].getMdBits();
          DCValue[] values=item.getMetadata(md[0],md[1],md[2],Item.ANY);
          if (values != null) {
            for (int x=0; x < values.length; x++) {
              String nVal=BrowseOrder.makeSortString(values[x].value,values[x].language,bis[i].getDataType());
              Map sortMap=getSortValues(item,itemMDMap);
              dao.insertIndex(bis[i].getTableName(),item.getID(),values[x].value,nVal,sortMap);
              if (bis[i].isMetadataIndex()) {
                int distinctID=dao.getDistinctID(bis[i].getTableName(true,false,false),values[x].value,nVal);
                dao.createDistinctMapping(bis[i].getMapName(),item.getID(),distinctID);
              }
            }
          }
        }
      }
    }
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    throw new BrowseException(e);
  }
}