harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Ivanov (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-2436) Reading from a closed Jar file is allowed
Date Mon, 04 Dec 2006 14:12:21 GMT
Reading from a closed Jar file is allowed

                 Key: HARMONY-2436
                 URL: http://issues.apache.org/jira/browse/HARMONY-2436
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Anton Ivanov
            Priority: Minor

Reading from InputStream which was opened on some JarFile
is allowed even if this JarFile was closed .

java.util.jar.JarFile inherits close() method from java.util.zip.ZipFile and
specification of this method ensure that if JarFile is closed all InputStreams that were obtained

via getInputStream() method will be closed. But JarFile behaves in a different manner.

Code to reproduce this problem:

import java.util.jar.*;
import java.io.*;
public class TestJarFileClose{

    public static void main(String[] args) {
        byte[] b = new byte[1024];
        try {
            JarFile jf = new JarFile("hello_world.jar");
            InputStream is = jf.getInputStream(jf.getEntry("hello_world/HelloWorld.class"));
            int r = is.read(b, 0, 1024);
            System.out.println("Test failed, readed from closed JAR file: "+r);
        } catch (Exception e) {
            System.out.println("Test passed: "+e);    

Output on RI:  
Test passed: java.lang.IllegalStateException: zip file closed

Output on Harmony: 
Test failed, readed from closed JAR file: 427 

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message