RFR(m) 2: 8072722: add stream support to Scanner

Stuart Marks stuart.marks at oracle.com
Wed Sep 9 21:32:08 UTC 2015



On 9/9/15 12:50 AM, Paul Sandoz wrote:
>> << After stream execution completes, this scanner is left in an indeterminate state and cannot be reused. >>
>
> Ah, shame, which strongly suggests advising that the stream/scanner should always be closed afterwards, regardless of whether it contains a resource to be released. Not sure we need to say anything, up to you.

Sure, closing the Scanner (or a Stream derived from it) will prevent inadvertent 
reuse.

But I think this is similar to a Stream, which need only be closed if it 
contains a resource. If it doesn't contain a resource, the fluent API makes it 
easy to just throw it away. For example,

     String text = ... ;
     long wordCount = new Scanner(text).findAll("\\w+").count();

I'm thus leaning against recommending that the Scanner or its derived Stream be 
closed in all cases.

On 9/9/15 1:04 AM, Chris Hegarty wrote:
> the webrev/specdiff uses the term ‘pipeline execution’. I think ‘stream execution’ is less likely to cause confusion.

I'll change the occurrences of "pipeline execution" to "stream pipeline 
execution" per your exchange with Paul. Looks like there are two such 
occurrences in each of the tokens() and findAll() methods.

Thanks for the reviews!

s'marks




More information about the core-libs-dev mailing list