You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Dmitri Blinov (JIRA)" <ji...@apache.org> on 2016/04/18 18:12:25 UTC

[jira] [Commented] (JEXL-193) InterruptedException is swallowed in function call in silent and non-strict mode

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

Dmitri Blinov commented on JEXL-193:
------------------------------------

I've been able to fix it locally by patching Interpreter.java 

{code}
    public Object interpret(JexlNode node) {
    ....
        } catch (JexlException xjexl) {
            if (xjexl instanceof JexlException.Cancel) {
                throw xjexl;
            } else if (silent) {
                logger.warn(xjexl.getMessage(), xjexl.getCause());
                return null;
            }
            throw xjexl.clean();
        ...
{code}

and adding additional catch 

{code}
    protected Object call(final JexlNode node, Object target, Object functor, final ASTArguments argNode) {
        ...
        } catch (InvocationTargetException ite) {

            Throwable targetException = ite.getTargetException();

            if (targetException instanceof InterruptedException) {
               throw new JexlException.Cancel(node);
            }

            xjexl = new JexlException(node, methodName, ite);
      ....
{code}

Hope this'll help to fix it...

> InterruptedException is swallowed in function call in silent and non-strict mode
> --------------------------------------------------------------------------------
>
>                 Key: JEXL-193
>                 URL: https://issues.apache.org/jira/browse/JEXL-193
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dmitri Blinov
>
> The following test case fails with 
> {code}
> java.lang.AssertionError: Values should be different. Actual: 42
> 	at org.junit.Assert.fail(Assert.java:88)
> 	at org.junit.Assert.failEquals(Assert.java:185)
> 	at org.junit.Assert.assertNotEquals(Assert.java:161)
> {code}
> {code}
>     public static class TestContext extends MapContext implements JexlContext.NamespaceResolver {
>         public int interrupt() throws InterruptedException {
>             throw new InterruptedException();
>         }
>     }
>     @Test
>     public void testInterrupt() throws Exception {
>         JexlEngine jexl = new JexlBuilder().arithmetic(new JexlArithmetic(false)).strict(false).silent(true).create();
>         JexlScript e = jexl.createScript("interrupt(); return 42");
>         Callable<Object> c = e.callable(new TestContext());
>         Object t = c.call();
>         Assert.assertNotEquals(42, t);
>     }
> {code}
> Expected behaviour is to cancel script execution



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)