commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ate Douma (JIRA)" <>
Subject [jira] [Created] (JEXL-245) Engine in strict mode fails to fail on unsolvable variables or properties
Date Fri, 01 Dec 2017 17:05:00 GMT
Ate Douma created JEXL-245:

             Summary: Engine in strict mode fails to fail on unsolvable variables or properties

                 Key: JEXL-245
             Project: Commons JEXL
          Issue Type: Bug
    Affects Versions: 3.1
            Reporter: Ate Douma

I've been running into some weird and unexpected behavior where the expectancy is that the
Engine throws a unsolvable property exception.

Example code:

import org.apache.commons.jexl3.*;

public class JexlTest {

    public Object getBar() {
        return null;

    private static void testJexl(final JexlEngine engine, final JexlContext ctx, final String
expression) {
        System.out.print("test ("+expression+"): ");
        try {
        } catch (JexlException e) {

    public static void main(final String[] args) throws Exception {
        MapContext ctx = new MapContext();
        JexlEngine engine = new JexlBuilder().strict(true).silent(false).create();
        ctx.set("foo", new JexlTest());
        testJexl(engine, ctx, "");
        testJexl(engine, ctx, "");
        testJexl(engine, ctx, "foo.baz");
Which produces the following output:
test ( null
test ( null
test (foo.baz): JexlTest.testJexl@1:4 unsolvable property 'baz'

The problem with the the second test, where accessing the property of the non-existing
variable bar is not throwing an exception.
The third test demonstrates a similar/same scenario where accessing the non-existing property
foo.baz is throwing the expected exception. 

This message was sent by Atlassian JIRA

View raw message