Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

已关闭 适合新手
#1,148 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@Aias00 已经在做这个了。

开始于 2026年9月30日。

  • #1158 来自 @Aias00 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java
领域
backend

调研方向

从第172-182行和第270-273行的 CsvWorkbook#createSheet 开始,然后检查第659-665行附近的 CsvWorkbook#write 和 CsvSheet。通过公开的 ExcelWriter API 重现该问题,并添加回归测试。完成的标准是:创建第二个逻辑 CSV sheet 会引发运行时异常,且发生在缓冲行可能丢失之前。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Java
星标
6.3k
派生
545
平均合并
2 天 22 小时
30 天内合并 PR
41

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/fesod 的其他 Issue

查看 apache/fesod 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。