TrueZIP
  1. TrueZIP
  2. TRUEZIP-279

ResourceController$ResourceOutputStream.close() et al should stop accounting for the resource unless a control flow exception gets thrown

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: TrueZIP 7.5.5
    • Fix Version/s: TrueZIP 7.6
    • Component/s: TrueZIP Kernel
    • Labels:
      None

      Description

      Issue is described on the mailing list: http://java.net/projects/truezip/lists/users/archive/2012-07/message/11

      TFile.cp(File, File) does not always close all streams that it opens. This has been seen in a case where an attempt was made to copy a virus file to a zip. The virus scanner would block/remove the concerning file, triggering a FileNotFoundException somewhere deep inside the truezip framework:

      FileNotFoundException(Throwable).<init>(String) line: 198
      FileNotFoundException(Exception).<init>(String) line: not available
      FileNotFoundException(IOException).<init>(String) line: not available
      FileNotFoundException.<init>(String, String) line: not available
      FileInputStream.open(String) line: not available [native method]
      FileInputStream.<init>(File) line: not available
      FileInputSocket.newInputStream() line: 43
      ZipOutputShop$BufferedEntryOutputStream.storeBuffer() line: 385
      ZipOutputShop$BufferedEntryOutputStream.close() line: 368
      FsMultiplexedOutputShop$EntryOutputStream.close() line: 202
      DisconnectingOutputShop$DisconnectingOutputStream.close() line: 250
      LockOutputStream.close() line: 85
      FsResourceController$ResourceOutputStream.close() line: 352
      FsSyncController.close(Closeable) line: 297
      FsSyncController$SyncOutputStream.close() line: 527
      FsLockController$1Close.call() line: 620
      FsLockController$1Close.call() line: 617
      FsLockController.locked(IOOperation<T>, Lock) line: 364
      FsLockController.writeLocked(IOOperation<T>) line: 303
      FsLockController.close(Closeable) line: 625
      FsLockController$LockOutputStream.close() line: 612
      FsFinalizeController$FinalizeOutputStream.close() line: 340
      Streams.copy(InputStream, OutputStream) line: 78
      IOSocket<LT,PT>.copy(InputSocket<?>, OutputSocket<?>) line: 118
      TBIO.cp0(boolean, File, File) line: 221
      TBIO.cp(boolean, File, File) line: 208
      TFile.cp(File, File) line: 2994
      ...

      This FileNotFoundException prevents FsResourceController$ResourceOutputStream.close() from deregistering the stream with the FsResourceController.

      A possible work-around

        Activity

        Hide
        Christian Schlichtherle added a comment -

        Changeset: 4e5d379c976c
        Author: Christian Schlichtherle <christian AT schlichtherle DOT de>
        Date: 2012-07-18 15:19
        Message: Another fix.
        Issue #TRUEZIP-279 - ResourceController$ResourceOutputStream.close() et al should stop accounting for the resource unless a control flow exception gets thrown

        Show
        Christian Schlichtherle added a comment - Changeset: 4e5d379c976c Author: Christian Schlichtherle <christian AT schlichtherle DOT de> Date: 2012-07-18 15:19 Message: Another fix. Issue # TRUEZIP-279 - ResourceController$ResourceOutputStream.close() et al should stop accounting for the resource unless a control flow exception gets thrown
        Hide
        Christian Schlichtherle added a comment -

        Please try the new attachments and let me know your results.

        Show
        Christian Schlichtherle added a comment - Please try the new attachments and let me know your results.
        Hide
        arjohn added a comment -

        First results look good. The problems with the small test that I used are gone. I'll try a larger test now. This will take a couple of hours to complete, so I'll report back tomorrow morning.

        Show
        arjohn added a comment - First results look good. The problems with the small test that I used are gone. I'll try a larger test now. This will take a couple of hours to complete, so I'll report back tomorrow morning.
        Hide
        Christian Schlichtherle added a comment -

        Great. Meanwhile I'll review the entire controller chain to check if I need to apply the pattern there, too.

        Show
        Christian Schlichtherle added a comment - Great. Meanwhile I'll review the entire controller chain to check if I need to apply the pattern there, too.
        Hide
        arjohn added a comment -

        All is looking fine here. I haven't seen any truezip issues during today's testing with the last snapshot.

        Show
        arjohn added a comment - All is looking fine here. I haven't seen any truezip issues during today's testing with the last snapshot.

          People

          • Assignee:
            Christian Schlichtherle
            Reporter:
            arjohn
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: