forked from shrinkwrap/shrinkwrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only export ArchiveAssets that have content
- Loading branch information
Showing
1 changed file
with
4 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
31e9e33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this isEmpty() check necessary?
31e9e33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there seems to be an edge case in the JVM-provided ZipOutputStream implementation that causes the underlying JdkZipExporterDelegate to bail on zero-length content archives.
https://github.com/gpoul/shrinkwrap/blob/master/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/exporter/zip/JdkZipExporterDelegate.java#L71
31e9e33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes. I've had fun with that before; glad I noted it as such. My memory is just about the worst. :)
31e9e33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even still, I think we have a gap here. Nowhere in the API docs does it note that "null" is an acceptable return value:
http://docs.jboss.org/shrinkwrap/1.0.0-beta-4/org/jboss/shrinkwrap/api/asset/Asset.html
How about instead: new ByteArrayInputStream(new byte[]{}); ?
31e9e33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even better...whatever content represents a valid this.exporter will no content? We could get around the JDK ZIP limitation by using another tool to generate an empty ZIP archive, putting that in src/main/resources, and return a new InputStream with that as the byte content.
31e9e33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that "If this returns null, this denotes that the Asset is to be viewed as a logical path (placeholder/directory) only with no backing content." would cover this case just fine... (?)
31e9e33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe, but this isn't a logical path. It's an empty archive. Directories in ShrinkWrap are denoted by Node with getAsset==null. http://docs.jboss.org/shrinkwrap/1.0.0-beta-4/org/jboss/shrinkwrap/api/Node.html#getAsset()
31e9e33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c7fb6d3