Skip to content

[CSV-333] Close the CSV output when flushing fails - #647

Open
hutiefang76 wants to merge 1 commit into
apache:masterfrom
hutiefang76:frank/fix-csv333-close-after-flush-20261205
Open

hutiefang76 wants to merge 1 commit into
apache:masterfrom
hutiefang76:frank/fix-csv333-close-after-flush-20261205

Conversation

@hutiefang76

Copy link
Copy Markdown

Jira: CSV-333, reported by Qiuye Wang.

If the optional flush throws, CSVPrinter.close(boolean) exits without closing its underlying writer. Always attempt to close a Closeable output after flushing, including when close() flushes through autoFlush. Keep the original flush failure and attach a distinct close failure as suppressed. If the writer throws the same exception instance twice, keep it without attempting to suppress it on itself.

Four regression cases fail on the original code and pass with this change. The default Maven build on Java 17 passed with 982 tests executed and 11 existing skips. On Java 8, CSVPrinterTest passed with 165 tests executed and seven existing skips. All four new cases ran on both JDKs.

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance.
  • AI assistance: DeepSeek V4 Pro helped develop the regressions and reviewed the patch. OpenAI Codex prepared the final code and pull request text, and verified the test results.
  • Run a successful build using the default Maven goal.
  • Add tests that fail without the runtime fix.
  • Describe the problem, approach, and validation.
  • Use a meaningful commit message with Assisted-By trailers.

Attempt to close the underlying writer after an optional flush fails.
Preserve the flush failure and suppress a distinct close failure.

Assisted-By: DeepSeek V4 Pro
Assisted-By: OpenAI Codex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant