msa at allman.ms
Wed Jan 30 06:30:14 UTC 2008
This must have been on somebody's plate for a long time.
Attached please find a patch to correct an apparently unreported bug. At
least, I couldn't find one. The problem is that if a FileChannel is
truncated and its position was previously set beyond the new length of the
file, the position should be but isn't set to the new length of the file.
Heads up. I have kinda sorta tested this patch. I run a Mac OS X Leopard
system. I have tested this patch on that system, as applied to the
soylatte source code repository. More info on soylatte here:
http://landonf.bikemonkey.org/static/soylatte/. The gist of it is that
soylatte is a port of Sun's JDK 6 to Mac OS X. My test procedure was as
1. Get jdk7/jdk/test/java/nio/channels/FileChannel/Truncate.java from the
2. Compile and run Truncate on soylatte 1.0.1 (which is based on Sun's
JDK 6 something). Test reports failure as such:
Exception in thread "main" java.lang.RuntimeException: Position greater
3. Run Truncate on a patched version of soylatte (patch essentially
identical to attached file). Test completes normally without output. I
guess this means it passed.
I'm sending this in as a patch to OpenJDK and not soylatte because I know
this is a problem on Solaris, too. That is, I ran Truncate on jdk6u4 on
solaris 11 and it failed.
Obviously, this is not the only way to fix this problem. We could also do
this with a patch to FileChannelImpl.java. I'll let whoever's in charge
here make that call.
So, I hope this is helpful. I am ready and willing to respond to
feedback. I have tried to follow the guidelines in
(CCing Landon Fuller because he runs the Soylatte project.)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1406 bytes
More information about the core-libs-dev