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

TarArchiveOutputStream#finish doesn't flush content to underlying stream

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.1
    • 1.2
    • None
    • None

    Description

      Originally reported against Ant https://issues.apache.org/bugzilla/show_bug.cgi?id=50014

      The finish() method of TarOutputStream does not flush the TarBuffer to the
      underlying output stream. A subsequent flush() on the TarOutputStream
      unexpectedly does not flush all written data to the underlying stream.

      Case: If an outputStream is tied to a Socket OutputStream, the receiving server
      can be notified that the stream has finished by calling the
      Socket.shutdownOutput() method while still allowing the server to respond to
      the client e.g. for sending a status report of the finished data transfer. This
      is in particular usefull if the size of the stream is not known in advance such
      as for a tar stream generated on the fly at the client side.

      The above case relies on all data being sent to the server before invoking
      Socket.shutdownOutput(). The TarOutputStream finish() method suggests to be
      doing just this but in practice does not send any remaining data in the
      TarBuffer. Calling the TarOutputStream close() method is not an option in this
      case since this also closes the Socket connection.

      Quick fix: insert a buffer.flushBlock() statement at the end of the
      TarOutputStream.finish() method.

      Attachments

        Activity

          People

            Unassigned Unassigned
            bodewig Stefan Bodewig
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: