Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-505

Multiple Reads of One SevenZArchiveEntry Fails

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.20
    • 1.21
    • None
    • None

    Description

      I've run into a bug which occurs when attempting to read the same SevenZArchiveEntry stream multiple times. The following code illustrates the problem.

      File archive = new File("CC0 Images.7z");
      char[] password = "password".toCharArray();
      try (SevenZFile f = new SevenZFile(archive, password))
      {
        SevenZArchiveEntry entry = StreamSupport.stream(f.getEntries().spliterator(), false)
          .filter(e -> "alberta-amazing-attraction-banff-417074.jpg".equals(e.getName()))
          .findFirst().orElseGet(null);
        assert entry != null;
        for (int i = 0; i < 100; i++)
        {
          InputStream is = f.getInputStream(entry);
          BufferedImage img = ImageIO.read(is);
          assert img != null;
          System.out.println("Succeeded " + (i + 1) + " times");
        }
      }

      Below is the output I receive on version 1.20

      Succeeded 1 times
      Succeeded 2 times
      Exception in thread "main" java.io.IOException: Checksum verification failed
          at org.apache.commons.compress.utils.ChecksumVerifyingInputStream.read(ChecksumVerifyingInputStream.java:61)
          at org.apache.commons.compress.utils.ChecksumVerifyingInputStream.skip(ChecksumVerifyingInputStream.java:102)
          at org.apache.commons.compress.utils.IOUtils.skip(IOUtils.java:113)
          at org.apache.commons.compress.archivers.sevenz.SevenZFile.getCurrentStream(SevenZFile.java:1318)
          at org.apache.commons.compress.archivers.sevenz.SevenZFile.getInputStream(SevenZFile.java:1354)
          at org.abitoff.dmav.Test.main(Test.java:11)
      

       

       

      Attachments

        1. CC0 Images.7z
          29.39 MB
          Steven Fontaine

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            peterlee Peter Lee
            acid1103 Steven Fontaine
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 40m
                40m

                Slack

                  Issue deployment