Tim Ellison wrote:
Regis wrote:
I just read the spec, it doesn't say the read method is synchronized or
thread-safe.

Agreed.  The class description doesn't say anything about multiple threads.

I think BufferedInputStream just need to keep itself status consistent,
he never know how is the InputStream implemented, it's better to left
synchronous/asynchronous problems handled by the wrapped stream.

Well at the moment we have the methods on BufferedInputStream marked as
synchronized.  That will ensure the consistency of the state in the
buffered stream, and in the wrapped stream.

Relaxing the sync on close() would pass through the multi-threading
problems to the wrapped stream, but we still need to ensure the buffered
stream is consistent, and that is non-trivial too (see my patch on the
JIRA).
I think The consistency of wrapped stream should be assured by itself, BufferedInputStream should be transparent on this. But I tested, that RI also synchronized the read method. So if we follow RI, I think the patch may be the best solution.

Best Regards,
Regis.


Regards,
Tim

Reply via email to