Re: [GitHub] [roller] mbien opened a new pull request #96: Deprections, compiler warning fixes, local refactorings and JDK 17 support
Michael Bien <[email protected]> Sun, 11 Jul 2021 09:36:55 +0200
| Newsgroups | gmane.comp.java.roller.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Greg,
those are java 8 functional streams* - not IO streams. So they don't
really have to be closed, the method collect() "runs" the stream in this
example by putting all results into a list. There are no system
resources involved which would have to be freed.
this code snipped creates a stream from the list, wraps each element
into a WeblogEntryWrapper, then creates a list again. In future the pojo
could directly return a stream instead of a list, so the method would
only add a step to the stream like a pipeline (and return a stream too).
does this answer your question?
thanks for reviewing :)
best regards,
michael
*
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/package-summary.html
- - - -
https://mbien.dev
On 11.07.21 08:45, Greg Huber wrote:
> Maybe more of a java question, how do these streams get closed as
> wrappers are in used in the templates?
>
> org.apache.roller.weblogger.pojos.wrapper;
>
> public List<WeblogEntryWrapper> retrieveWeblogEntries(boolean
> publishedOnly) throws WebloggerException {
> return this.pojo.retrieveWeblogEntries(publishedOnly).stream()
> .map(entry -> WeblogEntryWrapper.wrap(entry,
> urlStrategy))
> .collect(Collectors.toList());
>
> }
>
> I always use a try-with-resources on these.
>
>
> On 10/07/2021 11:03, GitBox wrote:
>> mbien opened a new pull request #96:
>> URL: https://github.com/apache/roller/pull/96
>>
>>
>> Worked myself though the compiler warnings. This looks like a lot
>> of changes, but the individual changes are all very local.
>> * since most of the rawtype warnings were on Collections, I
>> updated a lot of the code to use more modern APIs instead of only
>> fixing the warnings (e.g List.of, streams, ...)
>> * extracted common reflection code to a utility class
>> * got rid of some deprecations
>> * some cleanup and improvements (~400 lines less code)
>> * JDK 17 support (runs still on 11)
>>
>>