Thanks, good stuff.

2017-02-24 6:29 GMT+01:00 Jacques Le Roux <[email protected]>:

> +1 for timeout
>
> Jacques
>
>
>
> Le 24/02/2017 à 01:12, Daniel Dekany a écrit :
>
>> There's a hidden feature in FreeMarker 2 that allows templates be
>> interrupted with Thread.interrupt(). This can be used to limit the
>> template execution time (one thread processes the template, the other
>> waits for it to finish with a timeout, and then interrupts the
>> template processing thread). To see this in action, go to
>> http://freemarker-online.kenshoo.com/ and enter some very long loop.
>> The processing will be aborted with timeout. The related part of the
>> source code is around here:
>> https://github.com/kenshoo/freemarker-online/blob/master/src
>> /main/java/com/kenshoo/freemarker/services/FreeMarkerService.java#L123
>>
>> That's the closes I can think of right now. But I'm open to ideas,
>> because this used to be concern if you allow users to write templates.
>>
>> The problem with limiting #list iterations is that you can nest
>> #list-s into each other, so it's easy to square, cube, etc. your
>> iteration limit. (There are other fun ways of doing infinitely running
>> templates too, like with recursion. That's why simply measuring how
>> long the template is running is certainly the most robust solution.)
>>
>> If you have some collections that you know shouldn't be fully listed,
>> then perhaps you should wrap those into your own TemplateSequenceModel
>> implementation.
>>
>>
>> Thursday, February 23, 2017, 3:14:06 PM, Christoph Rüger wrote:
>>
>> We would like to hook into loops (<#list>) to e.g. count the number of
>>> iterations and react based on some business conditions. For example stop
>>> with an Exception after 10k iterations.
>>>
>>> I would think about some kind of callback which we can register which is
>>> called by freemarker inside <#list> iterations, so that our callback code
>>> can do whatever is needed.
>>>
>>> Is something like that possible already (haven't checked code yet) or
>>> planned for FM3?
>>>
>>> Thanks
>>> Christoph
>>>
>>>
>


-- 
Christoph Rüger, Geschäftsführer
Synesty <https://synesty.com/> - Anbinden und Automatisieren ohne
Programmieren - Automatisierung, Schnittstellen, Datenfeeds

Xing: https://www.xing.com/profile/Christoph_Rueger2
LinkedIn: http://www.linkedin.com/pub/christoph-rueger/a/685/198

-- 
Synesty GmbH
Moritz-von-Rohr-Str. 1a
07745 Jena
Tel.: +49 3641 559649
Fax.: +49 3641 5596499
Internet: http://synesty.com

Geschäftsführer: Christoph Rüger
Unternehmenssitz: Jena
Handelsregister B beim Amtsgericht: Jena
Handelsregister-Nummer: HRB 508766
Ust-IdNr.: DE287564982

Reply via email to