Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
What changed in this PR
This PR hardens WriteContextImpl.finish() to reliably release writer resources even when completion callbacks or workbook writing fails, ensuring cleanup still runs and the original failure is preserved (with cleanup failures suppressed).
Changes:
- Run completion callbacks inside an exception boundary; on callback failure, skip workbook output but continue cleanup and rethrow the original exception with suppressed cleanup errors.
- Split workbook write and workbook close into separate try blocks so a write failure can’t skip
Workbook.close(). - Add regression tests covering callback failures, write failures (in-memory + streaming), repeated finish calls, suppressed cleanup failures, and
autoCloseStream(false).
| File | Description |
|---|---|
| fesod-sheet/src/main/java/org/apache/fesod/sheet/context/WriteContextImpl.java | Wrapes finish callbacks with exception handling, adjusts write/close control flow, and ensures cleanup failures are suppressed onto the primary failure. |
| fesod-sheet/src/test/java/org/apache/fesod/sheet/context/WriteContextFinishCleanupTest.java | Adds regression tests to validate resource cleanup and exception/suppression behavior across failure modes and configurations. |
Review effort: Lite
| * Invokes completion callbacks before writing the workbook. | ||
| */ | ||
| private void finishCallbacks(boolean onException) { | ||
| // executes the callback after all sheets has been fully written. |
Comment on lines
+97
to
+103
| } finally { | ||
| workbook.close(); | ||
| if (workbook instanceof SXSSFWorkbook) { | ||
| ((SXSSFWorkbook) workbook).dispose(); | ||
| } | ||
| output.close(); | ||
| } |
Copilot stopped reviewing on behalf of
alaahong due to an error
October 28, 2026 14:49
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Purpose of the pull request
Release writer resources when a completion callback or workbook write fails.
Closes #1278
What's changed?
Completion callbacks now run inside an exception boundary. If one fails, cleanup still runs, workbook output is skipped, and the original exception is rethrown with any cleanup failures suppressed.
Workbook writing and closing use separate try blocks so a write failure cannot skip
Workbook.close(). Stream ownership and callback order are unchanged.Added regression tests for callback failures and write failures in both in-memory and streaming XLSX modes, repeated finish calls, suppressed cleanup failures, and
autoCloseStream(false).Validation on JDK 21: 41 tests passed across the cleanup, handler, encryption, template, and output-stream test classes. Checkstyle passed during the build; Spotless passed for both changed files. The multi-JDK CI matrix has not been run locally.
Checklist