6984545: (fc) transferFrom does not throw NonReadableChannelException when target is size 0 and non-readable
Alan Bateman
Alan.Bateman at oracle.com
Tue Sep 14 20:38:04 PDT 2010
Rémi Forax wrote:
> :
> what if transferFromArbitraryChannel is used instead of
> transferFromFileChannel ?
>
> Rémi
> PS: I hope this sentence is correct in English
Your English is fine and it's a good question. In the arbitrary channel
(not a FileChannel) case then the transferFrom/transferTo methods would
need to attempt a read or write for the count == 0 case as they can't
tell from the channel type. The long standing behavior has been to do
nothing and so would require a bit of consideration before changing it.
In implementation terms this would mean reading with a buffer that has 0
bytes remaining. I'll create a bug as a reminder. It may be that the
spec needs to be clarified for this corner case. For now, I'd like to
restore the behavior for the FileChannel case as it is impacted by the
zero length file case.
-Alan.
More information about the nio-dev
mailing list