[Bug] Writing multiple sheets to CSV silently drops unflushed rows
维护者通常 1 天内回复
评估
调研方向
从第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-182fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/csv/CsvWorkbook.java:270-273fesod-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
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/fesod 的其他 Issue
-
[Enhancement] Allow static imports in test sources so AssertJ is usable可能已有人在做 @qiaolezi001 于 1 天前认领。 未关闭enhancement
难度 2/5 1-3 小时 新手友好度 69/100
维护者通常 1 天内回复
-
[Task] mvnw.cmd always shows as modified after cloning可能已有人在做 @yebuguntang 于 5 天前认领。 未关闭discussion welcome help wanted
难度 1/5 1 小时以内 新手友好度 91/100
维护者通常 1 天内回复
-
discussion welcome security waiting for feedback
难度 2/5 1-3 小时 新手友好度 62/100
apache/fesod#1184 · 1 个 reaction ·
维护者通常 1 天内回复
-
[Bug] xlsx stream write leaves temp file可能已有人在做 @nkuprins 于 23 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 75/100
apache/fesod#1137 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[Bug] A cell read into a ReadCellData field loses its row and column index可能已有人在做 @CodeMan-cmd 于 37 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
相似的 Issue
-
[BUG] micronaut-serde-oracle-jdbc-json brings a second OJDBC driver onto the runtime classpath可能已有人在做 @ZARAYACH 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
micronaut-projects/micronaut-serialization#1494 · 4 条评论 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 2 天内回复
-
code-health feature/sync OS/Android QA/Test-Plan-Specified QA/Yes
难度 2/5 1-3 小时 新手友好度 75/100
brave/brave-browser#60327 ·
维护者通常 1 天内回复
-
Type: Bug
难度 2/5 1-3 小时 新手友好度 65/100
it-at-m/raumreservierung#383 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
aws/context-ontology-accelerator#325 ·
维护者通常 1 天内回复