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

Allow to disable closing files in the finalizer of ZipFile

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.19
    • None
    • Compressors
    • None

    Description

      Apache POI uses commons-compress for handling ZipFiles. We found that it sometimes does some auto-close magic in the finalizer of the ZipFile class with printing out to stderr, see https://gitbox.apache.org/repos/asf?p=commons-compress.git;a=blob;f=src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java;h=23194560dace91d8052626f3bdc8f765f9c46d7e;hb=HEAD#l652.

       

      This has some shortcomings:

      • It prints to stderr which many large-scale applications try to avoid by using some logging framework, thus this output might "vanish" unseen in some installations or might cause unexpected side-effects
      • It prevents us from using tools for checking file leaks, e.g. we use https://github.com/kohsuke/file-leak-detector/ heavily for analyzing test-runs for leaked file-handles, but commons-compress prevents this because it "hides" the unclosed file from this functionality
      • The behavior of automatic closing and reporting the problem is non-reproducible because it depends on finalizer/garbage-collection and thus any re-runs or unit-tests usually do not show the same behavior

       

      There are some fairly simple options to improve this:

      • Allow to disable this functionality via configuration/system-property/...
      • Make this "pluggable" so a logging-framework can be plugged-in or closing can be prevented for certain runs

       

      I can provide a simple patch if you state which approach you think would make most sense here.

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dominik.stadler@gmx.at Dominik Stadler
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: