[ 
https://issues.apache.org/jira/browse/JEXL-255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16381642#comment-16381642
 ] 

Dmitri Blinov commented on JEXL-255:
------------------------------------

As far as I can understand, the problem comes from 
{{InterpreterBase.cancelled}} member that is set to {{true}} once 
{{InterrupedException}} is caught by iterpreter and left with it even when 
{{JexlException.Cancel}} has been thrown.

I think we can implement the same pattern as in java with 
{{Thread.interruped()}} / {{InterruptedException}}. The idea is to clear 
interruption status once the {{JexlException.Cancel}} exception is about to be 
thrown, so that we would have either the exception or the interruption status 
set. Once the exception is thrown and interruption status is cleared, the 
annotation may catch {{JexlException.Cancel}} and decide what to do with it, if 
the situation could be handled locally, or re-raise otherwise...

> Ability to continue interrupted scripts
> ---------------------------------------
>
>                 Key: JEXL-255
>                 URL: https://issues.apache.org/jira/browse/JEXL-255
>             Project: Commons JEXL
>          Issue Type: Improvement
>    Affects Versions: 3.1
>            Reporter: Dmitri Blinov
>            Priority: Major
>
> I'm trying to implement the {{@timeout}} annotation that should work like the 
> following
> {code:java}
> @timeout(15000) { return longrunningcall(); }
>  {code}
> The idea is to protect part of the script code from being executed 
> indefinitely or more than allowed by business rules. The script should 
> continue its evaluation after the {{@timeout}} annotation regardless of 
> whether the timeout has taken place or not.
> There is a straightforward implementation that starts guarding thread which 
> should invoke {{Thread.interrupt()}} for the thread executing the script. The 
> {{InterruptedException | JexlException.Cancel}} is then caught and swallowed 
> inside the {{processAnnotation()}} method, and if the guard thread has fired, 
> which means the timeout occured, the {{null}} value is returned.
> I expected the script to continue its evaluation after the exception is 
> processed inside {{processAnnotation()}} code, but the script nevertheless 
> throwed {{JexlException.Cancel}} as a result. The suggestion is to allow 
> script to continue its evaluation once {{InterruptedException}} or 
> {{JexlException.Cancel}} is processed. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to