Re: [GitHub] [roller] mbien opened a new pull request #96: Deprections, compiler warning fixes, local refactorings and JDK 17 support

2021-07-11 Thread Michael Bien

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 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)






[GitHub] [roller] mbien opened a new pull request #97: EscapeSourceCodePlugin

2021-07-11 Thread GitBox


mbien opened a new pull request #97:
URL: https://github.com/apache/roller/pull/97


   Simple weblog entry plugin which can be used to escape angle brackets from 
text within pre tags.
   
   It understands the common pattern of pre and code tag in succession which is 
used by javascript source code highlighters and doesn't escape code tags 
directly following pre.
   
   Hopefully useful for programmers which like to blog in html mode and simply 
paste code into pre tags without breaking the page.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@roller.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




Re: [GitHub] [roller] mbien opened a new pull request #96: Deprections, compiler warning fixes, local refactorings and JDK 17 support

2021-07-11 Thread Michael Bien
no worries. I remember the first time i heard of java getting streams my 
first thought was io too.


Streams are great as long you don't overuse them.

-michael

On 11.07.21 10:09, Greg Huber wrote:


Sorry you are right, was thinking more of io streams, rather than 
java.util.Collection.stream.  Says it closes it once read, and should 
maintain the order.


too many ways of doing the same stuff.

On 11/07/2021 08:36, Michael Bien wrote:

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 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)