[jira] [Commented] (COMPRESS-571) 7z random access failes on shuffled entry list
[ https://issues.apache.org/jira/browse/COMPRESS-571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17303178#comment-17303178 ] Peter Lee commented on COMPRESS-571: Fixed with 65a5c75c. > 7z random access failes on shuffled entry list > -- > > Key: COMPRESS-571 > URL: https://issues.apache.org/jira/browse/COMPRESS-571 > Project: Commons Compress > Issue Type: Bug >Affects Versions: 1.20 >Reporter: Robin Schimpf >Assignee: Peter Lee >Priority: Major > > I noticed a problem on a 7z file and could reproduce the error if the > InputStream is retrieved after shuffling the entries. > This test fails with a checksum verification error > {code:java} > @Test > public void retrieveInputStreamForShuffledEntries() throws IOException { > try (final SevenZFile sevenZFile = new > SevenZFile(getFile("COMPRESS-256.7z"))) { > List entries = (List) > sevenZFile.getEntries(); > Collections.shuffle(entries); > for (final SevenZArchiveEntry entry : entries) { > IOUtils.toByteArray(sevenZFile.getInputStream(entry)); > } > } > } > {code} > This is the exception > {code:java} > java.io.IOException: Checksum verification failed > at > org.apache.commons.compress.utils.ChecksumVerifyingInputStream.read(ChecksumVerifyingInputStream.java:94) > at > org.apache.commons.compress.utils.ChecksumVerifyingInputStream.read(ChecksumVerifyingInputStream.java:74) > at org.apache.commons.compress.utils.IOUtils.copy(IOUtils.java:87) > at org.apache.commons.compress.utils.IOUtils.copy(IOUtils.java:62) > at > org.apache.commons.compress.utils.IOUtils.toByteArray(IOUtils.java:247) > at > org.apache.commons.compress.archivers.sevenz.SevenZFileTest.retrieveInputStreamForShuffledEntries(SevenZFileTest.java:616) > {code} > This also fails on the current master with the same error -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (COMPRESS-571) 7z random access failes on shuffled entry list
[ https://issues.apache.org/jira/browse/COMPRESS-571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17303144#comment-17303144 ] Stefan Bodewig commented on COMPRESS-571: - +1 to returning a copy. We already do in other places (for example when returning ZIP extra fields). I wonder why findbugs doesn't complain about the current code - at least it flags cases where you return the array directly. > 7z random access failes on shuffled entry list > -- > > Key: COMPRESS-571 > URL: https://issues.apache.org/jira/browse/COMPRESS-571 > Project: Commons Compress > Issue Type: Bug >Affects Versions: 1.20 >Reporter: Robin Schimpf >Priority: Major > > I noticed a problem on a 7z file and could reproduce the error if the > InputStream is retrieved after shuffling the entries. > This test fails with a checksum verification error > {code:java} > @Test > public void retrieveInputStreamForShuffledEntries() throws IOException { > try (final SevenZFile sevenZFile = new > SevenZFile(getFile("COMPRESS-256.7z"))) { > List entries = (List) > sevenZFile.getEntries(); > Collections.shuffle(entries); > for (final SevenZArchiveEntry entry : entries) { > IOUtils.toByteArray(sevenZFile.getInputStream(entry)); > } > } > } > {code} > This is the exception > {code:java} > java.io.IOException: Checksum verification failed > at > org.apache.commons.compress.utils.ChecksumVerifyingInputStream.read(ChecksumVerifyingInputStream.java:94) > at > org.apache.commons.compress.utils.ChecksumVerifyingInputStream.read(ChecksumVerifyingInputStream.java:74) > at org.apache.commons.compress.utils.IOUtils.copy(IOUtils.java:87) > at org.apache.commons.compress.utils.IOUtils.copy(IOUtils.java:62) > at > org.apache.commons.compress.utils.IOUtils.toByteArray(IOUtils.java:247) > at > org.apache.commons.compress.archivers.sevenz.SevenZFileTest.retrieveInputStreamForShuffledEntries(SevenZFileTest.java:616) > {code} > This also fails on the current master with the same error -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (COMPRESS-571) 7z random access failes on shuffled entry list
[ https://issues.apache.org/jira/browse/COMPRESS-571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17303127#comment-17303127 ] Robin Schimpf commented on COMPRESS-571: You are correct. Shuffling the list also shuffles the underlying array. This is also documented in the {{Arrays.asList}} JavaDoc {code:java} (Changes to the returned list "write through" to the array.) {code} So returning a copy seems to be the correct fix for this. The user of the class should not be able to change the internal representation with his actions > 7z random access failes on shuffled entry list > -- > > Key: COMPRESS-571 > URL: https://issues.apache.org/jira/browse/COMPRESS-571 > Project: Commons Compress > Issue Type: Bug >Affects Versions: 1.20 >Reporter: Robin Schimpf >Priority: Major > > I noticed a problem on a 7z file and could reproduce the error if the > InputStream is retrieved after shuffling the entries. > This test fails with a checksum verification error > {code:java} > @Test > public void retrieveInputStreamForShuffledEntries() throws IOException { > try (final SevenZFile sevenZFile = new > SevenZFile(getFile("COMPRESS-256.7z"))) { > List entries = (List) > sevenZFile.getEntries(); > Collections.shuffle(entries); > for (final SevenZArchiveEntry entry : entries) { > IOUtils.toByteArray(sevenZFile.getInputStream(entry)); > } > } > } > {code} > This is the exception > {code:java} > java.io.IOException: Checksum verification failed > at > org.apache.commons.compress.utils.ChecksumVerifyingInputStream.read(ChecksumVerifyingInputStream.java:94) > at > org.apache.commons.compress.utils.ChecksumVerifyingInputStream.read(ChecksumVerifyingInputStream.java:74) > at org.apache.commons.compress.utils.IOUtils.copy(IOUtils.java:87) > at org.apache.commons.compress.utils.IOUtils.copy(IOUtils.java:62) > at > org.apache.commons.compress.utils.IOUtils.toByteArray(IOUtils.java:247) > at > org.apache.commons.compress.archivers.sevenz.SevenZFileTest.retrieveInputStreamForShuffledEntries(SevenZFileTest.java:616) > {code} > This also fails on the current master with the same error -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (COMPRESS-571) 7z random access failes on shuffled entry list
[ https://issues.apache.org/jira/browse/COMPRESS-571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17303019#comment-17303019 ] Peter Lee commented on COMPRESS-571: With returning a copy of the entries, I can successfully finish this test. > 7z random access failes on shuffled entry list > -- > > Key: COMPRESS-571 > URL: https://issues.apache.org/jira/browse/COMPRESS-571 > Project: Commons Compress > Issue Type: Bug >Affects Versions: 1.20 >Reporter: Robin Schimpf >Priority: Major > > I noticed a problem on a 7z file and could reproduce the error if the > InputStream is retrieved after shuffling the entries. > This test fails with a checksum verification error > {code:java} > @Test > public void retrieveInputStreamForShuffledEntries() throws IOException { > try (final SevenZFile sevenZFile = new > SevenZFile(getFile("COMPRESS-256.7z"))) { > List entries = (List) > sevenZFile.getEntries(); > Collections.shuffle(entries); > for (final SevenZArchiveEntry entry : entries) { > IOUtils.toByteArray(sevenZFile.getInputStream(entry)); > } > } > } > {code} > This is the exception > {code:java} > java.io.IOException: Checksum verification failed > at > org.apache.commons.compress.utils.ChecksumVerifyingInputStream.read(ChecksumVerifyingInputStream.java:94) > at > org.apache.commons.compress.utils.ChecksumVerifyingInputStream.read(ChecksumVerifyingInputStream.java:74) > at org.apache.commons.compress.utils.IOUtils.copy(IOUtils.java:87) > at org.apache.commons.compress.utils.IOUtils.copy(IOUtils.java:62) > at > org.apache.commons.compress.utils.IOUtils.toByteArray(IOUtils.java:247) > at > org.apache.commons.compress.archivers.sevenz.SevenZFileTest.retrieveInputStreamForShuffledEntries(SevenZFileTest.java:616) > {code} > This also fails on the current master with the same error -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (COMPRESS-571) 7z random access failes on shuffled entry list
[ https://issues.apache.org/jira/browse/COMPRESS-571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17303018#comment-17303018 ] Peter Lee commented on COMPRESS-571: The _getEntries()_ returns exactly the same list of entries so the shuffle may also affect the same amout of entries. Maybe we should return a copy of entries in _getEntries()_ ? > 7z random access failes on shuffled entry list > -- > > Key: COMPRESS-571 > URL: https://issues.apache.org/jira/browse/COMPRESS-571 > Project: Commons Compress > Issue Type: Bug >Affects Versions: 1.20 >Reporter: Robin Schimpf >Priority: Major > > I noticed a problem on a 7z file and could reproduce the error if the > InputStream is retrieved after shuffling the entries. > This test fails with a checksum verification error > {code:java} > @Test > public void retrieveInputStreamForShuffledEntries() throws IOException { > try (final SevenZFile sevenZFile = new > SevenZFile(getFile("COMPRESS-256.7z"))) { > List entries = (List) > sevenZFile.getEntries(); > Collections.shuffle(entries); > for (final SevenZArchiveEntry entry : entries) { > IOUtils.toByteArray(sevenZFile.getInputStream(entry)); > } > } > } > {code} > This is the exception > {code:java} > java.io.IOException: Checksum verification failed > at > org.apache.commons.compress.utils.ChecksumVerifyingInputStream.read(ChecksumVerifyingInputStream.java:94) > at > org.apache.commons.compress.utils.ChecksumVerifyingInputStream.read(ChecksumVerifyingInputStream.java:74) > at org.apache.commons.compress.utils.IOUtils.copy(IOUtils.java:87) > at org.apache.commons.compress.utils.IOUtils.copy(IOUtils.java:62) > at > org.apache.commons.compress.utils.IOUtils.toByteArray(IOUtils.java:247) > at > org.apache.commons.compress.archivers.sevenz.SevenZFileTest.retrieveInputStreamForShuffledEntries(SevenZFileTest.java:616) > {code} > This also fails on the current master with the same error -- This message was sent by Atlassian Jira (v8.3.4#803005)