-
Notifications
You must be signed in to change notification settings - Fork 49
Throw specific exception when creating empty archive using single file archiver #61
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
Throw specific exception when creating empty archive using single file archiver #61
Conversation
…e archiver Currently archivers that accept single file (like BZip2Archiver) will throw `NoSuchElementException`. Modify them to throw `EmptyArchiveException` so they are consistent with `TarArchiver` and `ZipArchiver`. And it makes more sense.
The more I think about this, the more I think this need some differentiation. Zip files and directories can be empty, can't they? As for single file like gzip, bz2, xz, snappy, you are right. |
Yes, as far I know it is perfectly fine to create empty zip or tar file. As a matter of fact there is
Maybe we could add additional flag that indicates if you want to allow the creation of empty archive. Maybe we should have two separate hierarchies for archives (zip, tar, etc) and single compressed files (gzip, bzip2, etc). Things like And as a note, while we are discussing empty archives we should include the update mode into consideration as well. |
Maybe I should split this pull request. |
@plamentotev Yes, this makes sense. I still think that empty tar or zip files are fine and should be configurable, but this is another issue. Please split and I will merge. |
Closing in favor of #63 |
@plamentotev I am waiting for the second split PR for the single file archivers. I want to push 3.5 today or tomorrow. |
@michael-o looks like I misunderstood you about them. Here is the second PR - #64 |
With the merge of #51
EmptyArchiveException
is introduced. But it is thrown only by tar and zip (jar/war etc) archives. Archivers that accpet only single file (such asSnappyArchiver
) throwNoSuchElementException
.Closes #52
p.s. This reminds me that there is a lot of duplicated code.
BZip2Archiver
,GZipArchiver.java
& co are practically the same, maybe some day we should refactor them to eliminate the code duplication.