8078891: java.io.SequenceInputStream.close is not atomic and not idempotent

Pavel Rappo pavel.rappo at oracle.com
Fri Jul 26 19:37:11 UTC 2019

> On 26 Jul 2019, at 19:36, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> <snip>
> In any case, the change looks okay but it might be simpler to restructure to use:
> while (in != null) {
>     try { in.close() } catch (IOException e) { ... }
>     peekNextStream();
> }
> to simplify the error handling and avoid mixing nextStream and peekNextStream. There is also some curious code in peekNextStream where it handles nextElement returning null - I don't know the history on that but it looks like it's trying to handling a broken Enumeration.

For the record. If we change this as you suggested, the code will behave
differently in the case of a single `null` element found in the midst of
iteration (broken enumeration?). The stream won't be able to close after 
running into it. But this most likely is a programming error anyway. 

Not sure.

More information about the core-libs-dev mailing list