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

[COMPRESS] Change TarInputStream Skip Behavior

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.8.1
    • Component/s: Archivers
    • Labels:
      None

      Description

      InputStream#skip declares:

      Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, no bytes are skipped.

      I would recommend doing away with the call to the local IOUtils in the Stream's skip method and just call skip directly on the underlying stream. I'd also amend the JavaDoc to say "end up skipping .. some smaller number of bytes... reaching the end of the current entry." The stream is not required to make any best-effort. For your example, there should be a BufferedInputStream between the TarInputStream and the CipherInputStream. This would put it more in line with all other InputStreams.

      If a client wants to skip an entry manually, they would have to call Commons-IO IOUtils#skipFully, IOUtils#skip, etc.

      You would then have to modify getNextTarEntry() to call the IOUtils#skip method.

        Attachments

        1. TarArchiveInputStream.java.patch
          2 kB
          David Mollitor

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              belugabehr David Mollitor
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: