Alexei Fedotov wrote:
As for [1], it seems the following should be done under synchronized
(bais) {}. Imagine the thread will switch right after bais.pos check
and someone will read few bytes from the stream. In this case only a
part of the buffer should be returned.

        if (bais.pos == 0) {
            bais.skip(bais.buf.length);
            return bais.buf;
        }

[1] http://issues.apache.org/jira/secure/attachment/12378007/ByteStream.java

Agreed.

Tim

Reply via email to