Repository navigation
Conversation
Signed-off-by: liuhy <liuhongyu@apache.org>
skytin1004
reviewed
Oct 22, 2026
| Assertions.assertEquals(-1, source.read()); | ||
| } | ||
| } | ||
| assertFilled(streamOutput); |
Contributor
There was a problem hiding this comment.
Hi @Aias00, thanks for working on this.
I reproduced one remaining issue on Windows. With a file output and autoCloseStream(false), the caller-owned template stream stays open as intended, but the FileOutputStream created internally by Fesod also stays open. As a result, the generated XLS and XLSX files remain locked after finish().
Could you separate template-input ownership from internally created output ownership, and add a regression assertion that the generated file can be deleted or moved after finish()? Once this is covered, I think this will be ready to merge. Thanks!
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
Related: #185
Reduce the extra heap required by
withTemplate(...).build()without changing template fill behavior.Previously Fesod copied an entire template into a byte array and retained it until writer finish,
alongside POI's parsed workbook. InputStream templates additionally incurred a growing
ByteArrayOutputStream buffer and its final array copy.
This addresses the redundant template-copy overhead, not fully streaming template filling.
POI's parsed template workbook still resides in memory, including with
inMemory(false).What's changed?
Preserve
autoCloseStream(false)for caller-owned streams using the existing commons-io dependency.a template-present flag.
output cleanup when template I/O failures move from eager copying to POI initialization;
cleanup failures are suppressed rather than replacing the original failure.
row shifting, append writes, source ownership, parser/I/O/callback failures and suppressed errors.
Allocation check
A local JDK 17 probe measured allocations on the current thread during WriteWorkbookHolder
construction, using a 32 MiB generated stream or a 32 MiB file. It warmed up five times and took
the minimum of three measured runs. The generated source does not allocate a 32 MiB input array.
Baseline classes were built from
0045070c1556d824e45851327e719867ec89a9d6.These numbers measure template preparation only, not total workbook heap or POI parsing.
Validation
33,554,432 bytes instead of zero; it passes after the change.
stream was not closed; it passes with the cleanup in place.
./mvnw -B -pl fesod-common,fesod-shaded,fesod-sheet -Dtest.excludedGroups=fuzz package:1,795 tests passed (60 common + 1,735 sheet), with no failures or skips.
WriteWorkbookHolderOutputStreamTest.
./mvnw -B -pl fesod-common,fesod-shaded,fesod-sheet spotless:check./mvnw -B -pl fesod-common,fesod-shaded,fesod-sheet -Dmaven.javadoc.skip=false javadoc:javadocChecklist