harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vladimir Strigun (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-70) java.io.FileInputStream.close() must close channel associated with this FileInputStream
Date Mon, 20 Feb 2006 09:47:24 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-70?page=comments#action_12367017 ] 

Vladimir Strigun commented on HARMONY-70:
-----------------------------------------

Look like this issue already have been fixed in Harmony-42. I can't reproduce it with the
latest sources.

> java.io.FileInputStream.close() must close channel associated with this FileInputStream
> ---------------------------------------------------------------------------------------
>
>          Key: HARMONY-70
>          URL: http://issues.apache.org/jira/browse/HARMONY-70
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Vladimir Ivanov

>
> J2SE 1.4 specification reads for the method java.io.FileInputStream.close() :
> "If this stream has an associated channel then the channel is closed as well."
> But the channel is still opened.
> Code to reproduce:
> import java.io.*; 
> import java.nio.channels.*;
> public class test29 { 
>     public static void main(String[] args)  {
>         try { 
>             File f = File.createTempFile("temp", ".txt"); 
>             f.deleteOnExit(); 
>             FileInputStream fis = new FileInputStream(f); 
>             FileChannel fch = fis.getChannel(); 
>             fis.close();
>             System.out.println("fch.isOpen = " + fch.isOpen()); 
>         } catch (Exception e) { 
>             System.out.println("unex = " + e); 
>         } 
>     } 
> }  
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test29.java using BEA 1.4 javac 
> > javac -d . test29.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test29
> Output:
> C:\tmp\tmp17>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test29
> java version "1.4.2_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM  (build ari-31788-20040616-1132-win-ia32, Native
Threads, GC strategy: parallel)
> fch.isOpen = false
> C:\tmp\tmp17>C:\harmony\trunk\deploy\jre\bin\java -showversion test29
> java version 1.4.2 (subset)
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable.
> fch.isOpen = true
> junit test:
> ------------------------ FileInputStreamTest.java -------------------------------------------------
> import java.io.*; 
> import java.nio.channels.*;
> import junit.framework.*; 
> public class FileInputStreamTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(FileInputStreamTest.class); 
>     } 
>     public void testClose() { 
>         try { 
>             File f = File.createTempFile("temp", ".txt"); 
>             f.deleteOnExit(); 
>             FileInputStream fis = new FileInputStream(f); 
>             FileChannel fch = fis.getChannel(); 
>             fis.close();
>             assertFalse("FAILED, channel still opened!", fch.isOpen()); 
>         } catch (Exception e) { 
>             fail("Unexpected exception: " + e); 
>         } 
>     }
> } 

-- 
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


Mime
View raw message