John Fallows wrote:
Folks,

I think there might be a bug in AbstractIoBuffer.getSlice(index, length) in
Mina 2.0.0-M3.

    public final IoBuffer getSlice(int index, int length) {
        if (length < 0) {
            throw new IllegalArgumentException("length: " + length);
        }
        int pos = position();
        int limit = limit();
        int endIndex = *pos* + length;
        ...
        limit(endIndex);

Shouldn't that be:

        int endIndex = *index* + length;
        ...
        limit(endIndex);

Otherwise, the wrong slice would be returned if index differs from the
current position, right?
Seems right.

FYI, the IoBuffer class is likely to be removed in the final version of MINA, and AFAIK, the getSlice( int, int ) method is neither used nor documented, so the question is : does it worth the effort to fix it and document it ? It seems that YAGNI hasen't been applied in this area ... (http://en.wikipedia.org/wiki/You_Ain%27t_Gonna_Need_It)

Thanks for pointing the bug (I will fix it)

Btw, you should either post such a mail to the dev mailing list, or better, create a JIRA (with possibly a proposed patch).

--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org


Reply via email to