Program: 58715
Project: 58715
Buggy source:
/** 
 * Method create domain xml file from MetaModel. It create one single domain xml string for domain and write it to file. Also call method to process fields.
 * @param modelIterator MetaModel iterator
 * @throws IOException Exception thrown by file handling of domain xml file.
 * @throws AxelorException 
 */
private void recordModel(Iterator<MetaModel> modelIterator) throws IOException, AxelorException {
  if (!modelIterator.hasNext()) {
    return;
  }
  moduleSequenceMap=new HashMap<String,StringBuilder>();
  moduleFieldMap=new HashMap<String,StringBuilder>();
  MetaModel metaModel=modelIterator.next();
  String packageName=metaModel.getPackageName();
  String modelName=metaModel.getName();
  trackFields=new ArrayList<String>();
  updateSequenceXml(metaModel.getMetaSequenceList().iterator());
  List<MetaField> customFields=getCustomisedFields(metaModel,true);
  if (customFields.isEmpty()) {
    log.debug("String_Node_Str",metaModel.getName());
    configService.removeDomainFile(metaModel.getName() + "String_Node_Str");
    recordModel(modelIterator);
    return;
  }
  sortFieldList(customFields);
  addFields(customFields.iterator());
  for (  String module : moduleFieldMap.keySet()) {
    String sequenceXml="String_Node_Str";
    StringBuilder sequenceBuilder=moduleSequenceMap.get(module);
    if (sequenceBuilder == null) {
      sequenceXml=sequenceXml.toString();
    }
    String fieldXml=moduleFieldMap.get(module).toString();
    StringBuilder sb=new StringBuilder("String_Node_Str").append("String_Node_Str").append("String_Node_Str").append(NAMESPACE).append("String_Node_Str").append("String_Node_Str").append("String_Node_Str").append(NAMESPACE).append("String_Node_Str").append(NAMESPACE + "String_Node_Str" + "String_Node_Str"+ VERSION+ "String_Node_Str").append("String_Node_Str").append("String_Node_Str").append("String_Node_Str" + module.replace("String_Node_Str","String_Node_Str") + "String_Node_Str"+ packageName+ "String_Node_Str").append(sequenceXml + "String_Node_Str").append("String_Node_Str" + modelName + "String_Node_Str").append(fieldXml).append(getTrackFields()).append("String_Node_Str").append("String_Node_Str");
    File domainFile=new File(configService.getDomainDir(module,true),modelName + "String_Node_Str");
    writeFile(domainFile,sb.toString());
  }
  recordModel(modelIterator);
}

Fixed version (ground truth):
/** 
 * Method create domain xml file from MetaModel. It create one single domain xml string for domain and write it to file. Also call method to process fields.
 * @param modelIterator MetaModel iterator
 * @throws IOException Exception thrown by file handling of domain xml file.
 * @throws AxelorException 
 */
private void recordModel(MetaModel metaModel) throws IOException, AxelorException {
  moduleSequenceMap=new HashMap<String,StringBuilder>();
  moduleFieldMap=new HashMap<String,StringBuilder>();
  String packageName=metaModel.getPackageName();
  String modelName=metaModel.getName();
  trackFields=new ArrayList<String>();
  updateSequenceXml(metaModel.getMetaSequenceList().iterator());
  List<MetaField> customFields=getCustomisedFields(metaModel,true);
  if (customFields.isEmpty()) {
    log.debug("String_Node_Str",metaModel.getName());
    configService.removeDomainFile(metaModel.getName() + "String_Node_Str");
    return;
  }
  sortFieldList(customFields);
  addFields(customFields.iterator());
  for (  String module : moduleFieldMap.keySet()) {
    String sequenceXml="String_Node_Str";
    StringBuilder sequenceBuilder=moduleSequenceMap.get(module);
    if (sequenceBuilder == null) {
      sequenceXml=sequenceXml.toString();
    }
    String fieldXml=moduleFieldMap.get(module).toString();
    StringBuilder sb=new StringBuilder("String_Node_Str").append("String_Node_Str").append("String_Node_Str").append(NAMESPACE).append("String_Node_Str").append("String_Node_Str").append("String_Node_Str").append(NAMESPACE).append("String_Node_Str").append(NAMESPACE + "String_Node_Str" + "String_Node_Str"+ VERSION+ "String_Node_Str").append("String_Node_Str").append("String_Node_Str").append("String_Node_Str" + module.replace("String_Node_Str","String_Node_Str") + "String_Node_Str"+ packageName+ "String_Node_Str").append(sequenceXml + "String_Node_Str").append("String_Node_Str" + modelName + "String_Node_Str").append(fieldXml).append(getTrackFields()).append("String_Node_Str").append("String_Node_Str");
    File domainFile=new File(configService.getDomainDir(module,true),modelName + "String_Node_Str");
    writeFile(domainFile,sb.toString());
  }
}