-line-ness.
With best regards,
Tagir Valeev.
>
> Rémi
>
> - Original Message -
> > From: "Brian Goetz"
> > To: "Tagir Valeev" , "core-libs-dev"
> >
> > Sent: Lundi 27 Septembre 2021 22:41:00
> > Subject: Re: Discussion
gt; Sent: Lundi 27 Septembre 2021 22:41:00
> Subject: Re: Discussion: easier Stream closing
> In Java 8, I think we were reluctant to lean on the idiom of "pass me a
> lambda and I'll pass it the confined data"), because Java developers
> were already struggling to understa
Hello, Brian! Thanks for your thoughts.
> The consumeAndClose approach is clever, in that it adds one API point that
> works for all streams, rather than having to add a new API point for every
> factory of a closeable stream; on the other hand, it is dramatically less
> discoverable, and so re
In Java 8, I think we were reluctant to lean on the idiom of "pass me a
lambda and I'll pass it the confined data"), because Java developers
were already struggling to understand lambdas. But now that we're
mostly over that hurdle, API points that accept Consumer are
a powerful way to gain con
On Sun, Sep 26, 2021 at 6:13 PM Remi Forax wrote:
>
> > List list =
> > Files.list(Path.of("/etc")).map(Path::getFileName).consumeAndClose(Stream::toList);
> >
> > What do you think?
>
> This one does not work because if Path::getFileName fails with an exception,
> close() will not be called.
We
On Sun, 26 Sept 2021 at 10:29, Tagir Valeev wrote:
> List list =
> Files.list(Path.of("/etc")).map(Path::getFileName).consumeAndClose(Stream::toList);
>
> What do you think?
I fully support this. We have our own utility to do this kind of
thing, as bugs with `Files` are common:
https://github.com
- Original Message -
> From: "Tagir Valeev"
> To: "core-libs-dev"
> Sent: Dimanche 26 Septembre 2021 11:27:58
> Subject: Discussion: easier Stream closing
> Hello!
>
> With current NIO file API, a very simple problem to get the list of
&
Hello!
With current NIO file API, a very simple problem to get the list of
all files in the directory requires some ceremony:
List paths;
try (Stream stream = Files.list(Path.of("/etc"))) {
paths = stream.toList();
}
If we skip try-with-resources, we may experience OS file handles leak,
so i