Program: 147630
Project: 147630
Buggy source:
protected int exportCluster(TMDMService service,String tempFolderPath,String dName,IProgressMonitor monitor){
  String encodedID=null;
  WsDataClusterPK pk=new WsDataClusterPK(dName);
  try {
    List<String> items=new ArrayList<String>();
    List<WsItemPKsByCriteriaResponseResults> results=service.getItemPKsByCriteria(new WsGetItemPKsByCriteria(null,null,(long)-1,null,null,MAX_EXPORT_COUNT,0,(long)-1,pk)).getResults();
    if (results == null) {
      return -1;
    }
    monitor.beginTask(Messages.ExportDataClusterAction_exportContent,results.size() + 10);
    monitor.subTask(Messages.ExportDataClusterAction_exporting);
    int totalSize=0;
    int maxSize=results.size() - 1;
    if (maxSize > 0) {
      totalSize=Integer.parseInt(Util.parse(results.get(0).getWsItemPK().getConceptName()).getDocumentElement().getTextContent());
      if (maxSize > MAX_EXPORT_COUNT) {
        maxSize=MAX_EXPORT_COUNT;
      }
    }
    Mapping mapping=getWSItemMapping();
    for (int i=1; i <= maxSize; i++) {
      WsItemPKsByCriteriaResponseResults item=results.get(i);
      WsItem wsitem=service.getItem(new WsGetItem(item.getWsItemPK()));
      StringWriter sw=new StringWriter();
      Marshaller marshaller=new Marshaller(sw);
      marshaller.setMapping(mapping);
      marshaller.marshal(wsitem);
      String uniqueId=pk.getPk() + "String_Node_Str" + wsitem.getConceptName();
      for (      String id : wsitem.getIds()) {
        uniqueId=uniqueId + "String_Node_Str" + id;
      }
      encodedID=URLEncoder.encode(uniqueId,"String_Node_Str");
      writeString(tempFolderPath,sw.toString(),pk.getPk() + "String_Node_Str" + encodedID);
      items.add(TreeObject.DATACONTAINER_COTENTS + "String_Node_Str" + pk.getPk()+ "String_Node_Str"+ encodedID);
      monitor.worked(1);
    }
    return totalSize;
  }
 catch (  Exception e) {
    log.error(e.getMessage(),e);
  }
  return -1;
}

Fixed version (ground truth):
protected int exportCluster(TMDMService service,String tempFolderPath,String dName,IProgressMonitor monitor){
  String encodedID=null;
  WSDataClusterPK pk=new WSDataClusterPK(dName);
  try {
    List<String> items=new ArrayList<String>();
    List<WSItemPKsByCriteriaResponseResults> results=service.getItemPKsByCriteria(new WSGetItemPKsByCriteria(null,null,(long)-1,null,null,MAX_EXPORT_COUNT,0,(long)-1,pk)).getResults();
    if (results == null) {
      return -1;
    }
    monitor.beginTask(Messages.ExportDataClusterAction_exportContent,results.size() + 10);
    monitor.subTask(Messages.ExportDataClusterAction_exporting);
    int totalSize=0;
    int maxSize=results.size() - 1;
    if (maxSize > 0) {
      totalSize=Integer.parseInt(Util.parse(results.get(0).getWsItemPK().getConceptName()).getDocumentElement().getTextContent());
      if (maxSize > MAX_EXPORT_COUNT) {
        maxSize=MAX_EXPORT_COUNT;
      }
    }
    Mapping mapping=getWSItemMapping();
    for (int i=1; i <= maxSize; i++) {
      WSItemPKsByCriteriaResponseResults item=results.get(i);
      WSItem wsitem=service.getItem(new WSGetItem(item.getWsItemPK()));
      StringWriter sw=new StringWriter();
      Marshaller marshaller=new Marshaller(sw);
      marshaller.setMapping(mapping);
      marshaller.marshal(wsitem);
      String uniqueId=pk.getPk() + "String_Node_Str" + wsitem.getConceptName();
      for (      String id : wsitem.getIds()) {
        uniqueId=uniqueId + "String_Node_Str" + id;
      }
      encodedID=URLEncoder.encode(uniqueId,"String_Node_Str");
      writeString(tempFolderPath,sw.toString(),pk.getPk() + "String_Node_Str" + encodedID);
      items.add(TreeObject.DATACONTAINER_COTENTS + "String_Node_Str" + pk.getPk()+ "String_Node_Str"+ encodedID);
      monitor.worked(1);
    }
    return totalSize;
  }
 catch (  Exception e) {
    log.error(e.getMessage(),e);
  }
  return -1;
}