-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When UnzipUtil.createZipInputStream(ZipModel, FileHeader, char[]) throws an Exception it doesn't close InputStreams #58
Labels
bug
Something isn't working
Comments
I used the following code to test, and this code deletes the zip file. I tested it on a mac though. Which os are you using? Does your tests (or user running the tests) have the rights to delete a file?
|
I’m using Windows. And if I remove the call to
UnzipUtil.createZipInputStream() (or if that call succeeds) then the code is able to delete the file. The delete only fails when
UnzipUtil.createZipInputStream() fails to open the zip file.
Sent from Yahoo Mail for iPad
On Thursday, September 5, 2019, 1:36 AM, Srikanth Reddy Lingala <notifications@github.com> wrote:
I used the following code to test, and this code deletes the zip file. I tested it on a mac though. Which os are you using? Does your tests (or user running the tests) have the rights to delete a file?
ZipFile zipFile = new ZipFile("/Users/slingala/Downloads/test.zip", "password".toCharArray());
ZipParameters zipParameters = new ZipParameters();
zipParameters.setEncryptFiles(true);
zipParameters.setEncryptionMethod(EncryptionMethod.AES);
zipFile.addFile(TestUtils.getTestFileFromResources("sample.pdf"), zipParameters);
try {
zipFile = new ZipFile("/Users/slingala/Downloads/test.zip");
zipFile.extractAll("/Users/slingala/Downloads/");
} catch (Exception e) {
assertThat(zipFile.getFile().delete()).isTrue();
throw e;
}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I was able to reproduce on Windows with the below code:
I will include a fix for it. |
srikanth-lingala
added a commit
that referenced
this issue
Sep 8, 2019
Fixed in v2.1.3 released today |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a unit test asserting that a file is password protected. As an assertion on that, I check that opening the zip file with a null password fails. However when I do that, the file being asserted upon becomes undeletable due to the unclosed input streams this method creates.
The text was updated successfully, but these errors were encountered: