Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-6644

[classlib][archive] ZipFile(File) does not close the stream if ZipException occurs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 5.0M14
    • None
    • Classlib
    • None
    • Windows XP
    • Patch Available

    Description

      run below test case, the observed output is "false" while the expected output is "true".
      The cause is if ZipException occurs, the mRaf field is not closed.
      Thus file stream and system resources associated with the stream are not released.
      Thus failed to delete the file on Windows platform.

      import java.io.File;
      import java.io.IOException;
      import java.util.zip.*;

      import tests.support.Support_PlatformFile;

      public class ZipFileBug {

      public static void main (String [] args) throws IOException {
      ZipFile zip;
      String emptyFileName = System.getProperty("user.dir");
      if (emptyFileName.charAt(emptyFileName.length() - 1) == File.separatorChar)

      { emptyFileName = Support_PlatformFile.getNewPlatformFile( emptyFileName, "empty.zip"); }

      else

      { emptyFileName = Support_PlatformFile.getNewPlatformFile( emptyFileName + File.separatorChar, "empty.zip"); }


      File emptyFile = new File(emptyFileName);
      emptyFile.createNewFile();
      try

      { zip = new ZipFile(emptyFile, ZipFile.OPEN_READ); }

      catch (ZipException ze) {
      }
      System.out.println(emptyFile.delete());
      }
      }

      Attachments

        1. JIRA-6644-v2.diff
          3 kB
          Xiao Shu
        2. JIRA-6644.diff
          3 kB
          Xiao Shu

        Activity

          People

            Unassigned Unassigned
            xiaoshu Xiao Shu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: