[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fwd: FYI: Fix RandomAccessFile.setLenght (truncation file, updates
From: |
Michael Koch |
Subject: |
Re: [Fwd: FYI: Fix RandomAccessFile.setLenght (truncation file, updates file position).] |
Date: |
Sat, 1 May 2004 10:55:57 +0200 |
User-agent: |
KMail/1.5.4 |
Am Samstag, 1. Mai 2004 02:19 schrieb Mark Wielaard:
> Hi Michael,
>
> On Fri, 2004-04-30 at 07:57, Michael Koch wrote:
> > Areyou sure the bug isnt in FileChannelImpl.truncate(long) ? have
> > you checked this ?
>
> Good catch. Indeed the bug is in FileChannelImpl.truncate().
> I have created a bunch of Mauve tests for it.
> Unfortunately it has more then one bug.
> It also has a bug were it allowed truncate() to actually expand the
> File which isn't allowed. Attached are some patches for this
> including a new implementation of RandomAccessFile.setLength() to
> only use truncate for making the file smaller and using seek for
> expanding the file.
>
> 2004-04-30 Mark Wielaard <address@hidden>
>
> * gnu/java/nio/channels/FileChannelImpl.java (truncate): Only
> truncate when size is smaller.
> * native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
> (implTruncate): Always save current position. Only reposition
> file pointer to where we started if not beyond new lenght. Reposition
> file pointer to file length if it points beyond the end of file. *
> java/io/RandomAccessFile.java (setLength): Use truncate for shrinking
> the file and seek plus write for expanding the file.
>
> This makes all Mauve tests pass (including the new ones). And no
> regressions. I think this is the best we can do for this release. In
> the future we might want an extra native/VM method for expanding
> and/or truncating explicitly.
>
> What do you think. OK for this release?
> We can also go with what we have now, then FileChannel.truncate()
> will be broken (two ways), but RandomAccessFile.setLength() will be
> correct.
I think this is okay for release as its backed by (new) mauve tests and
should be relatively bugfree.
Michael
- Re: [Fwd: FYI: Fix RandomAccessFile.setLenght (truncation file, updates file position).],
Michael Koch <=