Closing the Stream returned from BufferedReader.lines()

Sam Pullara spullara at gmail.com
Sun Dec 1 21:29:01 PST 2013


This must be a bug, right? Isn't this the reason we added AutoCloseable to streams?

Sam

On Dec 1, 2013, at 7:03 PM, Zhong Yu <zhong.j.yu at gmail.com> wrote:

> In this code
> 
>        BufferedReader br = ...;
>        Stream<String> stream = br.lines();
>        stream.close();  // does not close `br`
> 
> `stream.close()` does not trigger `br.close()`. I for one find that
> rather counter-intuitive. Can you guys explain the design choice? When
> should a Stream forward close() to its source and when should it not?
> 
> see http://stackoverflow.com/questions/20319417
> 
> Zhong Yu
> 



More information about the lambda-libs-spec-experts mailing list