RFR  SequenceInputStream with lots of empty substreams can cause StackOverflowError
Alan.Bateman at oracle.com
Sun Mar 2 10:50:11 UTC 2014
On 02/03/2014 07:58, Ivan Gerasimov wrote:
> SequenceInputStream#read functions are implemented recursively.
> This may cause stack overflow in some extreme cases with lots of empty
> Would you please help review the fix?
> BUGURL: https://bugs.openjdk.java.net/browse/7011804
> WEBREV: http://cr.openjdk.java.net/~igerasim/7011804/0/webrev/
Thanks for taking one. I don't think this code has changed much since
JDK 1.0 where it seems to have been originally implemented to use
recursion. I'm dubious about the bug report and whether the usage is
real or made-up to demonstrate the issue.
In any case, the changes good to me. One comment in passing is that
normally an InputStream read throws IOException when the stream is
closed where as SIS returns EOF. There may be an opportunity to clarify
the javadoc in a few places (not for this bug of course).
The test looks okay. I agree with Chris that there shouldn't be a need
to run it in its own VM.
More information about the core-libs-dev