You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Peter Lee <pe...@gmail.com> on 2019/12/19 07:17:52 UTC

[Compress]Discussion about COMPRESS-499

Hi all.

A recent issue COMPRESS-499(
https://issues.apache.org/jira/projects/COMPRESS/issues/COMPRESS-499)
discussed about a potential problem in SeekableInMemoryByteChannel.
Based on the java docs(
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/channels/SeekableByteChannel.html#truncate(long
)), I believe there are some problems in the  SeekableInMemoryByteChannel .
The method repositionIfNecessary() may change the position of the channel,
which may be a bug basing on the docs, and it's called in read and
truncate. I'm not an expert on SeekableByteChannel, and I'm not sure if
SeekableInMemoryByteChannel is doing this intentionally or not.

What do you think?

cheers,
Lee

Re: [Compress]Discussion about COMPRESS-499

Posted by Stefan Bodewig <bo...@apache.org>.
On 2019-12-19, Peter Lee wrote:

> Hi all.

> A recent issue COMPRESS-499(
> https://issues.apache.org/jira/projects/COMPRESS/issues/COMPRESS-499)
> discussed about a potential problem in SeekableInMemoryByteChannel.
> Based on the java docs(
> https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/channels/SeekableByteChannel.html#truncate(long
> )), I believe there are some problems in the  SeekableInMemoryByteChannel .

Agreed.

> The method repositionIfNecessary() may change the position of the channel,
> which may be a bug basing on the docs, and it's called in read and
> truncate. I'm not an expert on SeekableByteChannel, and I'm not sure if
> SeekableInMemoryByteChannel is doing this intentionally or not.

I agree with your suggestion to add tests that verify we adhere to the
SeekableByteChannel contract for (more or less) all methods.

I've looked through the commit history and - as the one who introduced
repositionIfNecessary - believe it is just wrong. Even if existing tests
fail when it gets adjusted this may just indicate I haven't read up on
the interface's contract properly when I wrote the tests. :-)

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org