commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Bodewig (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (COMPRESS-418) ZipArchiveEntry duplicates the size field from ZipEntry
Date Tue, 18 Jul 2017 15:14:00 GMT

    [ https://issues.apache.org/jira/browse/COMPRESS-418?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16091691#comment-16091691
] 

Stefan Bodewig commented on COMPRESS-418:
-----------------------------------------

Hmm, I don't think it is related to {{ZipArchiveEntry}} shadowing its parent's field, {{getSize}}
should always return {{ZipArchiveEntry}}'s value.

What I think is happening here is that when creating the archive, the size has been stored
inside the data descriptor after the entry contents, so {{getSize}} won't give you a correct
answer until the content has been read completely. See http://commons.apache.org/proper/commons-compress/zip.html#ZipArchiveInputStream_vs_ZipFile
and http://commons.apache.org/proper/commons-compress/javadocs/api-release/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.html#getSize--

I'd recommend using {{ZipFile}} when reading the archive as you are reading from a file anyway.

> ZipArchiveEntry duplicates the size field from ZipEntry
> -------------------------------------------------------
>
>                 Key: COMPRESS-418
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-418
>             Project: Commons Compress
>          Issue Type: Bug
>          Components: Archivers
>    Affects Versions: 1.14
>         Environment: Java 1.8.0_131
> Apache Compress 1.14
>            Reporter: Darryl L. Pierce
>            Priority: Critical
>
> I create an archive using Apache Compress. I can read the archive fine using 7zip and
JAR (from the JDK).
> When I read the same archive using Apache Compress libraries, I get a NegativeArraySizeException
on every entry.
> When I read any other archive using Apache Compress libraries, I do not get the NegativeArraySizeException
on entries.
> When I debug this, I see that the ZipArchiveEntry object has two instance variables named
size (one it defines, which contains the correct size, and one it inherits from ZipEntry which
is -1). And it seems that, on Apache Compress-created archives, it's always returning the
inherited value and not the one defined by ZipArchiveEntry.
> In my code, I am only use instances of ZipArchiveEntry.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message