harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Elena Sayapina (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-4408) [classlib][luni] FileInputStream.close() is called two times to close FileInputStream
Date Tue, 10 Jul 2007 12:32:06 GMT
[classlib][luni] FileInputStream.close() is called two times to close FileInputStream

                 Key: HARMONY-4408
                 URL: https://issues.apache.org/jira/browse/HARMONY-4408
             Project: Harmony
          Issue Type: Improvement
          Components: Classlib
            Reporter: Elena Sayapina
            Priority: Minor

FileInputStream.close() method is called two times to close FileInputStream.

Simple test below shows that FileInputStream.close() called two times to close FileInputStream,

Namely method close() calls itself through AbstractInterruptibleChannel.close() 
So call stack is the looks like: FileInputStream.close() -> AbstractInterruptibleChannel.close()
-> FileChannelImpl.implCloseChannel() -> FileInputStream.close()

Most probably this implementation issue is OK, but it looks a little intricate

Please, consider the following code:

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class closeTest {

	public static void main(String[] args) throws IOException {
		File file = new File("test.txt");
	                     TestFileInputStream is = new TestFileInputStream(file.getName());
		System.out.println("Method TestFileInputStream.close() was called " + is.num_called + "
class TestFileInputStream extends FileInputStream {

	public int num_called = 0;
	public TestFileInputStream(String path) throws IOException {

                     public void close() throws IOException {

Output on Harmony-r552422:

Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r552422, (Jul  2 2007), Windows/ia32/msvc 1310, release build

Method TestFileInputStream.close() was called 2 time(s)

Output on RI:

java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)

Method TestFileInputStream.close() was called 1 time(s)

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

View raw message