[
https://issues.apache.org/jira/browse/MSHADE-417?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17516308#comment-17516308
]
Max Zerzouri commented on MSHADE-417:
-------------------------------------
Looking at the changes in that PR, I would guess it's because of these lines in
{{ZipHeaderPeekInputStream.hasZipHeader}}:
{code:java}
final byte[] header = new byte[HEADER_LEN];
super.read( header, 0, HEADER_LEN );
super.unread( header );
{code}
It always pushes back the entirety of that byte array (4 bytes,
{{HEADER_LEN}}), even though {{super.read}} could have read less than 4 bytes.
The remaining bytes in the {{header}} array will naturally be 0. It should
probably be looking at the return value of {{super.read}} to know how many
bytes to actually {{unread}}.
> Nul bytes appended to small files by maven-shade-plugin
> -------------------------------------------------------
>
> Key: MSHADE-417
> URL: https://issues.apache.org/jira/browse/MSHADE-417
> Project: Maven Shade Plugin
> Issue Type: Bug
> Affects Versions: 3.3.0
> Reporter: Max Zerzouri
> Priority: Major
> Attachments: original-shadetest-0.0.0.jar, pom.xml,
> shadetest-0.0.0.jar, test.txt
>
>
> Version 3.3.0 of maven shade plugin seems to append "\x00" bytes to a file if
> it's less than 4 bytes:
> {code:sh}
> $ echo -n a > src/main/resources/test.txt
> $ mvn clean install
> ...
> $ bsdtar -xOf target/original-shadetest-0.0.0.jar test.txt | xxd
> 00000000: 61 a
> $ bsdtar -xOf target/shadetest-0.0.0.jar test.txt | xxd
> 00000000: 6100 0000 a...
> {code}
> I've attached a basic {{pom.xml}} that triggers this. This doesn't occur in
> the previous version, 3.2.4.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)