Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Bug] Writing multiple sheets to CSV silently drops unflushed rows

Chiusa Adatta ai principianti
#1,148 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Aias00 ci sta già lavorando.

Dal 30/9/2026.

  • #1158 di @Aias00 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
backend

Direzione di ricerca

Iniziare da CsvWorkbook#createSheet alle righe 172-182 e 270-273, quindi esaminare CsvWorkbook#write e CsvSheet intorno alle righe 659-665. Riprodurre il problema tramite l’API pubblica ExcelWriter e aggiungere un test di regressione. Il lavoro è completo quando la creazione di un secondo foglio CSV logico genera un’eccezione a runtime prima che le righe memorizzate nel buffer possano andare perse.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Fesod version

Current main at 5a9a16b.

Description

Writing two distinct WriteSheet instances through one CSV ExcelWriter succeeds without an exception, but rows buffered by the earlier sheet are silently discarded.

Location
  • fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/csv/CsvWorkbook.java:172-182
  • fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/csv/CsvWorkbook.java:270-273
  • fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/csv/CsvSheet.java:659-665

CsvWorkbook#createSheet uses assert csvSheet == null to enforce the single-sheet CSV contract. Assertions are disabled in normal JVM runs, so a second sheet replaces the only csvSheet reference. CsvWorkbook#write then closes and flushes only the replacement sheet.

Reproduction
try (ExcelWriter writer = FesodSheet.write(file)
        .excelType(ExcelTypeEnum.CSV)
        .build()) {
    writer.write(Collections.singletonList(Collections.singletonList("first-row")),
            FesodSheet.writerSheet(0).build());
    writer.write(Collections.singletonList(Collections.singletonList("second-row")),
            FesodSheet.writerSheet(1).build());
}

The resulting CSV contains only second-row. With 101 rows in the first sheet, the first 100 rows are flushed, row 101 is lost, and the second sheet is appended. No exception is raised.

Expected behavior

CSV should reject creation of a second logical sheet with a normal runtime exception before any data can be lost.

Suggested fix

Replace the assert checks in both createSheet overloads with an explicit guard and add a regression test through the public writer API.

Related existing work

Issue #103 concerns parallel writing of multiple Excel sheets. It does not cover CSV silently discarding buffered rows.

Are you willing to submit a PR?

Yes.

Lingua principale
Java
Stelle
6.3k
Fork
545
Merge medio
2g 22h
PR unite (30g)
41

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/fesod

Tutte le issue di apache/fesod

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.