You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Xiao Shu (JIRA)" <ji...@apache.org> on 2010/09/07 10:08:32 UTC

[jira] Created: (HARMONY-6644) [classlib][archive] ZipFile(File) does not close the stream if ZipException occurs

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

                 Key: HARMONY-6644
                 URL: https://issues.apache.org/jira/browse/HARMONY-6644
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
    Affects Versions: 5.0M14
         Environment: Windows XP
            Reporter: Xiao Shu


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());        
    }
}



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-6644) [classlib][archive] ZipFile(File) does not close the stream if ZipException occurs

Posted by "Xiao Shu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-6644?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xiao Shu updated HARMONY-6644:
------------------------------

    Attachment: JIRA-6644.diff

JIRA-6644.diff is the patch for this defect.

> [classlib][archive] ZipFile(File) does not close the stream if ZipException occurs
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-6644
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6644
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M14
>         Environment: Windows XP
>            Reporter: Xiao Shu
>         Attachments: JIRA-6644.diff
>
>
> 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());        
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-6644) [classlib][archive] ZipFile(File) does not close the stream if ZipException occurs

Posted by "Mark Hindess (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-6644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12908127#action_12908127 ] 

Mark Hindess commented on HARMONY-6644:
---------------------------------------

I mean that the regression test passes even without the fix on linux.


> [classlib][archive] ZipFile(File) does not close the stream if ZipException occurs
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-6644
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6644
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M14
>         Environment: Windows XP
>            Reporter: Xiao Shu
>         Attachments: JIRA-6644-v2.diff, JIRA-6644.diff
>
>
> 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());        
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-6644) [classlib][archive] ZipFile(File) does not close the stream if ZipException occurs

Posted by "Mark Hindess (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-6644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12907816#action_12907816 ] 

Mark Hindess commented on HARMONY-6644:
---------------------------------------

I tried the v2 patch and the regression test fails without the fix for me on linux.  I notice you have tagged this jira as windows xp but if it only fails on that platform then maybe the platform independent java code isn't the right place for the fix?


> [classlib][archive] ZipFile(File) does not close the stream if ZipException occurs
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-6644
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6644
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M14
>         Environment: Windows XP
>            Reporter: Xiao Shu
>         Attachments: JIRA-6644-v2.diff, JIRA-6644.diff
>
>
> 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());        
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-6644) [classlib][archive] ZipFile(File) does not close the stream if ZipException occurs

Posted by "Xiao Shu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-6644?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xiao Shu updated HARMONY-6644:
------------------------------

    Attachment: JIRA-6644-v2.diff

The JIRA-6644.diff patch missed an import statement.
Please fix it with JIRA-6644-v2.diff.

> [classlib][archive] ZipFile(File) does not close the stream if ZipException occurs
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-6644
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6644
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M14
>         Environment: Windows XP
>            Reporter: Xiao Shu
>         Attachments: JIRA-6644-v2.diff, JIRA-6644.diff
>
>
> 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());        
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-6644) [classlib][archive] ZipFile(File) does not close the stream if ZipException occurs

Posted by "Regis Xu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-6644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12909164#action_12909164 ] 

Regis Xu commented on HARMONY-6644:
-----------------------------------

You test whether the zip file is closed by trying to delete the file, this is not always validate. On Linux, you can delete file even another process has opened it.

> [classlib][archive] ZipFile(File) does not close the stream if ZipException occurs
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-6644
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6644
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M14
>         Environment: Windows XP
>            Reporter: Xiao Shu
>         Attachments: JIRA-6644-v2.diff, JIRA-6644.diff
>
>
> 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());        
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.