Program: 58701
Project: 58701
Buggy source:
/** 
 * Méthode réalisant l'export des FEC (Fichiers des écritures Comptables)
 * @throws AxelorException
 * @throws IOException
 */
@Transactional(rollbackOn={AxelorException.class,Exception.class}) public void exportMoveLineTypeSelect1000(MoveLineReport moveLineReport) throws AxelorException, IOException {
  log.info("String_Node_Str");
  List<String[]> allMoveLineData=new ArrayList<String[]>();
  Company company=moveLineReport.getCompany();
  String moveLineQueryStr="String_Node_Str";
  moveLineQueryStr+=String.format("String_Node_Str",company.getId());
  moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getYear().getId());
  if (moveLineReport.getPeriod() != null) {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getPeriod().getId());
  }
 else {
    if (moveLineReport.getDateFrom() != null) {
      moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getDateFrom().toString());
    }
    if (moveLineReport.getDateTo() != null) {
      moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getDateTo().toString());
    }
  }
  if (moveLineReport.getDate() != null) {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getDate().toString());
  }
  moveLineQueryStr+=String.format("String_Node_Str");
  List<MoveLine> moveLineList=moveLineRepo.all().filter("String_Node_Str" + moveLineQueryStr,MoveRepository.STATUS_VALIDATED).order("String_Node_Str").order("String_Node_Str").fetch();
  if (moveLineList.size() > 0) {
    for (    MoveLine moveLine : moveLineList) {
      String items[]=new String[18];
      Move move=moveLine.getMove();
      Journal journal=move.getJournal();
      items[0]=journal.getCode();
      items[1]=journal.getName();
      items[2]=moveLine.getName();
      items[3]=moveLine.getDate().toString("String_Node_Str");
      items[4]=moveLine.getAccount().getCode();
      items[5]=moveLine.getAccount().getName();
      items[6]=null;
      items[7]=null;
      items[8]=moveLine.getOrigin();
      items[9]=moveLine.getDate().toString("String_Node_Str");
      items[10]=moveLine.getDescription();
      items[11]=moveLine.getDebit().toString();
      items[12]=moveLine.getCredit().toString();
      if (moveLine.getDebit().compareTo(BigDecimal.ZERO) > 0) {
        List<String> ReconcileSeqList=new ArrayList<String>();
        List<String> ReconcileDateList=new ArrayList<String>();
        for (        Reconcile reconcile : moveLine.getDebitReconcileList()) {
          ReconcileSeqList.add(reconcile.getReconcileSeq());
          ReconcileDateList.add(reconcile.getReconciliationDate().toString("String_Node_Str"));
        }
        items[13]=StringUtils.join(ReconcileSeqList,"String_Node_Str");
        items[14]=StringUtils.join(ReconcileDateList,"String_Node_Str");
      }
 else {
        List<String> ReconcileSeqList=new ArrayList<String>();
        List<String> ReconcileDateList=new ArrayList<String>();
        for (        Reconcile reconcile : moveLine.getCreditReconcileList()) {
          ReconcileSeqList.add(reconcile.getReconcileSeq());
          ReconcileDateList.add(reconcile.getReconciliationDate().toString("String_Node_Str"));
        }
        items[13]=StringUtils.join(ReconcileSeqList,"String_Node_Str");
        items[14]=StringUtils.join(ReconcileDateList,"String_Node_Str");
      }
      items[15]=move.getValidationDate().toString("String_Node_Str");
      items[16]=moveLine.getCurrencyAmount().toString();
      if (move.getCurrency() != null) {
        items[17]=move.getCurrency().getCode();
      }
      allMoveLineData.add(items);
    }
  }
  String fileName=this.setFileName(moveLineReport);
  String filePath=accountConfigService.getExportPath(accountConfigService.getAccountConfig(company));
  new File(filePath).mkdirs();
  log.debug("String_Node_Str",filePath,fileName);
  CsvTool.csvWriter(filePath,fileName,'|',this.createHeaderForHeaderFile(moveLineReport.getTypeSelect()),allMoveLineData);
  moveLineReportRepo.save(moveLineReport);
  Path path=Paths.get(filePath + fileName);
  File file=path.toFile();
  MetaFile metaFile=metaFilesTemp.upload(file);
  MetaAttachment metaAttachment=metaFilesTemp.attach(metaFile,moveLineReport);
  metaAttachmentRepo.save(metaAttachment);
}

Fixed version (ground truth):
/** 
 * Méthode réalisant l'export des FEC (Fichiers des écritures Comptables)
 * @throws AxelorException
 * @throws IOException
 */
@Transactional(rollbackOn={AxelorException.class,Exception.class}) public void exportMoveLineTypeSelect1000(MoveLineReport moveLineReport) throws AxelorException, IOException {
  log.info("String_Node_Str");
  List<String[]> allMoveLineData=new ArrayList<String[]>();
  Company company=moveLineReport.getCompany();
  String moveLineQueryStr="String_Node_Str";
  moveLineQueryStr+=String.format("String_Node_Str",company.getId());
  moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getYear().getId());
  if (moveLineReport.getPeriod() != null) {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getPeriod().getId());
  }
 else {
    if (moveLineReport.getDateFrom() != null) {
      moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getDateFrom().toString());
    }
    if (moveLineReport.getDateTo() != null) {
      moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getDateTo().toString());
    }
  }
  if (moveLineReport.getDate() != null) {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getDate().toString());
  }
  moveLineQueryStr+=String.format("String_Node_Str");
  List<MoveLine> moveLineList=moveLineRepo.all().filter("String_Node_Str" + moveLineQueryStr,MoveRepository.STATUS_VALIDATED).order("String_Node_Str").order("String_Node_Str").fetch();
  if (moveLineList.size() > 0) {
    for (    MoveLine moveLine : moveLineList) {
      String items[]=new String[18];
      Move move=moveLine.getMove();
      Journal journal=move.getJournal();
      items[0]=journal.getCode();
      items[1]=journal.getName();
      items[2]=moveLine.getName();
      items[3]=moveLine.getDate().toString("String_Node_Str");
      items[4]=moveLine.getAccount().getCode();
      items[5]=moveLine.getAccount().getName();
      items[6]=null;
      items[7]=null;
      items[8]=moveLine.getOrigin();
      items[9]=moveLine.getDate().toString("String_Node_Str");
      items[10]=moveLine.getDescription();
      items[11]=moveLine.getDebit().toString();
      items[12]=moveLine.getCredit().toString();
      if (moveLine.getDebit().compareTo(BigDecimal.ZERO) > 0) {
        List<String> ReconcileSeqList=new ArrayList<String>();
        List<String> ReconcileDateList=new ArrayList<String>();
        for (        Reconcile reconcile : moveLine.getDebitReconcileList()) {
          ReconcileSeqList.add(reconcile.getReconcileSeq());
          ReconcileDateList.add(reconcile.getReconciliationDate().toString("String_Node_Str"));
        }
        items[13]=StringUtils.join(ReconcileSeqList,"String_Node_Str");
        items[14]=StringUtils.join(ReconcileDateList,"String_Node_Str");
      }
 else {
        List<String> ReconcileSeqList=new ArrayList<String>();
        List<String> ReconcileDateList=new ArrayList<String>();
        for (        Reconcile reconcile : moveLine.getCreditReconcileList()) {
          ReconcileSeqList.add(reconcile.getReconcileSeq());
          ReconcileDateList.add(reconcile.getReconciliationDate().toString("String_Node_Str"));
        }
        items[13]=StringUtils.join(ReconcileSeqList,"String_Node_Str");
        items[14]=StringUtils.join(ReconcileDateList,"String_Node_Str");
      }
      items[15]=move.getValidationDate().toString("String_Node_Str");
      items[16]=moveLine.getCurrencyAmount().toString();
      if (move.getCurrency() != null) {
        items[17]=move.getCurrency().getCode();
      }
      allMoveLineData.add(items);
    }
  }
  String fileName=this.setFileName(moveLineReport);
  String filePath=accountConfigService.getExportFileName(accountConfigService.getAccountConfig(company));
  new File(filePath).mkdirs();
  log.debug("String_Node_Str",filePath,fileName);
  CsvTool.csvWriter(filePath,fileName,'|',this.createHeaderForHeaderFile(moveLineReport.getTypeSelect()),allMoveLineData);
  moveLineReportRepo.save(moveLineReport);
  Path path=Paths.get(filePath + fileName);
  try (InputStream is=new FileInputStream(path.toFile())){
    Beans.get(MetaFiles.class).attach(is,fileName,moveLineReport);
  }
 }