fix: delete staged xlsx when encrypted stream write fails - #1147
Closed
kalayciburak wants to merge 1 commit into
Closed
kalayciburak wants to merge 1 commit into
kalayciburak wants to merge 1 commit into
Conversation
A password-protected xlsx written to a stream is staged in a temp file. If workbook.write fails and close succeeds, that file was left behind. Closed: apache#1137 Signed-off-by: kalayciburak <kalayciburak1996@gmail.com>
Contributor
|
Hi @kalayciburak, thanks for your interest in this! 🙂 I'd ticked "willing to submit a PR" on #1137 and was waiting for a maintainer to confirm the bug and the proposed fix before opening one. On the implementation:
Would you mind closing this so the fix can go ahead once the issue and fix are confirmed? Tip A small tip for next time: if an issue has "willing to submit a PR" ticked, a quick comment asking the author first saves duplicate work for both of us. Contributions are very welcome, and I'd be glad to see more from you! 🙏 |
Author
|
sorry, missed the willing-to-submit flag on #1137. your finally approach is cleaner than the extra wrote flag. closing this so you can open yours once the issue is confirmed. |
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
Closed: #1137
A password-protected xlsx written to an
OutputStreamis staged in a temp file bydoOutputStreamEncrypt07(). Ifworkbook.writefails and the followingclose()succeeds, that temp file was never deleted.What's changed?
After the stream is closed, delete the staged file when
write()did not succeed. The success path is unchanged: the file is still removed after encryption. Delete happens only afterclose(), so the unlink is not attempted while the stream still holds the file.Checklist
Test plan
JAVA_HOME=17 ./mvnw -pl fesod-sheet -Dtest=WriteContextImplEncryptTempFileTest -Dsurefire.failIfNoSpecifiedTests=false -Dmaven.test.skip=false test— 1/0. Before the fix the same test left the staged xlsx.JAVA_HOME=17 ./mvnw -pl fesod-sheet -Dtest=WriteContextImplEncryptTempFileTest,EncryptDataTest -Dsurefire.failIfNoSpecifiedTests=false -Dmaven.test.skip=false test— EncryptDataTest 4/0, no failures../mvnw -pl fesod-sheet spotless:check— clean.