8000330: (fc) FileChannel.truncate issues when given size > file size
Alan Bateman
Alan.Bateman at oracle.com
Sat Nov 3 14:20:01 PDT 2012
This mail concerns a couple of the issues that Jeff Hain has brought up
on the list in the last few days.
8000330 concerns the issues with FileChannel's truncate method when
invoked with a size that is greater than the current size. This case
doesn't change the file of course but it should change the channel's
position when it is beyond the given size. This case has an additional
corner case when the file is opened for reading that isn't handled
properly in the current implementation.
8002180 is just that FileChannel.map doesn't throw NullPointerException
when invoked with a MapMode of null.
The webrev with the proposed changes is here:
http://cr.openjdk.java.net/~alanb/8000330+8002180/webrev/
The changes are trivial, with most of the changes just adding additional
tests. They aren't issues that most applications are likely to run into
but they are issues that should have been caught by tests back in
jdk1.4. Note that the changes to MapTest are less than what might seem
initially, this is because I updated the existing test to use
try-with-resources. I should also note that FileChannelImpl.map is
deliberately not using Objects.requireNonNull, this is because there are
several pre-conditions to check and I'm trying to keep them consistent.
Thanks,
Alan.
More information about the nio-dev
mailing list