-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
mantis
-
sparc
-
solaris_2.6
-
Verified
Name: nkR10003 Date: 07/03/2002
The JavaDoc comments for RandomAccessFile.close() method says:
/**
* ...
*
* If this file has an associated channel then the channel is closed as well.
*
* ...
*
*/
This statement does not work.
Example below demonstrates this problem:
------------------example--------------------
import java.io.*;
import java.nio.channels.*;
public class test {
public static void main(String[] args) {
File f = new File("test.txt");
try {
f.createNewFile();
f.deleteOnExit();
RandomAccessFile raf = new RandomAccessFile(f, "r");
FileChannel channel = raf.getChannel();
raf.close();
if (channel.isOpen()) {
System.out.println("Test failed: channel is open");
System.exit(-1);
}
} catch (IOException e) {
System.out.println("Test failed: unexpected exception: " + e);
}
System.out.println("Test passed");
return;
}
}
----------------output:----------------------
%java -version
java version "1.4.1-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b16)
Java HotSpot(TM) Client VM (build 1.4.1-rc-b16, mixed mode)
%java test
Test failed: channel is open
---------------------------------------------
======================================================================