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

Stefan Bodewig commented on COMPRESS-528:
-----------------------------------------

I'm not sure your expectation is correct. {{getSize}} returns what an entry's 
metadata says, not necessarily what can be read. I'm not sure we are consistent 
here across the formats. In some of them we throw exceptions if the actual 
numbers don't match, in others - like tar - we silently accept it.

Changing something here could mean we'd start throwing exceptions for archives 
where we have not done so, so far. Also one needs to think about what happens 
if the content is never read like in code just invoking {{getNextEntry}} 
repeatedly in order to list the contents, for example.

> Tar decompression - Inconsistent entry size
> -------------------------------------------
>
>                 Key: COMPRESS-528
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-528
>             Project: Commons Compress
>          Issue Type: Bug
>    Affects Versions: 1.20
>            Reporter: Maksim Zuev
>            Priority: Major
>         Attachments: InconsistentSize.tar
>
>
> Expected that 
> {{[getSize|https://commons.apache.org/proper/commons-compress/javadocs/api-1.20/org/apache/commons/compress/archivers/tar/TarArchiveEntry.html#getSize--]()
>  }}returns the size of byte array read from ArchiveInputStream
> To reproduce run this Kotlin code(InconsistentSize.tar is in the attachment). 
> It fails with exception
> Exception in thread "main" java.lang.IllegalStateException: 19 expected but 0 
> found
>  at ru.example.kotlinfuzzer.tests.MainKt.main(main.kt:82)
>  at ru.example.kotlinfuzzer.tests.MainKt.main(main.kt)
> {code:java}
> import org.apache.commons.compress.archivers.ArchiveStreamFactory
> import java.io.File
> fun main() {
>     val tar = File("InconsistentSize.tar")
>     ArchiveStreamFactory().createArchiveInputStream("tar", 
> tar.inputStream()).use { ais ->
>         val expected = ais.nextEntry.size
>         val actual = ais.readAllBytes().size.toLong()
>         check(expected == actual) { "$expected expected but $actual found" }
>     }
> }
> {code}
> {{}}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to