commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Biestro (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (JEXL-181) Cannot create inline Map with array or function call as the key
Date Thu, 26 Nov 2015 21:45:11 GMT

     [ https://issues.apache.org/jira/browse/JEXL-181?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Henri Biestro resolved JEXL-181.
--------------------------------
       Resolution: Fixed
    Fix Version/s: 3.0

This is fixed in 3.0. The following test runs with no error.
{code}

    @Test
    public void testVariableMap() throws Exception {
        JexlScript script = JEXL.createScript("{ ['1', '2'.toString()] : someValue }", "someValue");
        Object result = script.execute(null, 42);
        Assert.assertTrue(result instanceof Map);
        Object key = null;
        Object value = null;
        for(Map.Entry<?,?> e : ((Map<?,?>) result).entrySet()) {
            key = e.getKey();
            value = e.getValue();
            break;
        }
        Object gg = ((Map) result).get(key);
        Assert.assertEquals(42, ((Number) gg).intValue());
        Assert.assertEquals(value, ((Number) gg).intValue());
    }
{code}

> Cannot create inline Map with array or function call as the key
> ---------------------------------------------------------------
>
>                 Key: JEXL-181
>                 URL: https://issues.apache.org/jira/browse/JEXL-181
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 2.1.1
>            Reporter: Balazs Zsoldos
>            Assignee: Henri Biestro
>             Fix For: 3.0
>
>
> It seems that inline maps can be created only if:
>  - the keys are string literals or a numbers
>  - the keys are variables
> The followings throw exception:
> {code}
> { ['1', '2'] : someValue }
> { myVar.callFunction() : someValue }
> {code}
> Example stacktrace for expression: { 'step'.toString() : [1, 2] }
> {code}
> org.apache.commons.jexl2.JexlException$Parsing: @1:21 parsing error near '... g() : [1,
 ...'
>      at org.apache.commons.jexl2.JexlEngine.parse(JexlEngine.java:1260)
>      at org.apache.commons.jexl2.JexlEngine.createScript(JexlEngine.java:506)
>      at org.everit.expression.jexl.JexlExpressionCompiler.compile(JexlExpressionCompiler.java:63)
>      at org.everit.templating.html.internal.HTMLNodeVisitor.compileExpression(HTMLNodeVisitor.java:174)
>      at org.everit.templating.html.internal.HTMLNodeVisitor.processEhtAttribute(HTMLNodeVisitor.java:406)
>      at org.everit.templating.html.internal.HTMLNodeVisitor.fillEhtTagNodeWithAttribute(HTMLNodeVisitor.java:190)
>      at org.everit.templating.html.internal.HTMLNodeVisitor.handleEWTNode(HTMLNodeVisitor.java:270)
>      at org.everit.templating.html.internal.HTMLNodeVisitor.visitTag(HTMLNodeVisitor.java:634)
>      at org.htmlparser.nodes.TagNode.accept(TagNode.java:700)
>      at org.everit.templating.html.HTMLTemplateCompiler.compile(HTMLTemplateCompiler.java:125)
>      at biz.everit.therapy.portal.WebTemplateRenderer.<init>(WebTemplateRenderer.java:57)
>      at biz.everit.therapy.series.demo.DemoSeriesServlet.<init>(DemoSeriesServlet.java:46)
>      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>      at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
>      at java.lang.Class.newInstance(Class.java:442)
>      at org.everit.osgi.ecm.component.ri.internal.ComponentContextImpl.starting(ComponentContextImpl.java:760)
>      at org.everit.osgi.ecm.component.ri.internal.ComponentContextImpl.open(ComponentContextImpl.java:564)
>      at org.everit.osgi.ecm.component.ri.internal.ComponentContainerImpl.open(ComponentContainerImpl.java:110)
>      at org.everit.osgi.ecm.extender.ri.internal.ECMCapabilityTracker.addingBundle(ECMCapabilityTracker.java:105)
>      at org.everit.osgi.ecm.extender.ri.internal.ECMCapabilityTracker.addingBundle(ECMCapabilityTracker.java:44)
>      at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:469)
>      at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:1)
>      at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
>      at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
>      at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)
>      at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:902)
>      at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
>      at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
>      at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:165)
>      at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:75)
>      at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:67)
>      at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:102)
>      at org.eclipse.osgi.container.Module.publishEvent(Module.java:466)
>      at org.eclipse.osgi.container.Module.start(Module.java:457)
>      at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:392)
>      at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:411)
>      at org.everit.osgi.dev.richconsole.internal.upgrade.UpgradeProcess.finish(UpgradeProcess.java:243)
>      at org.everit.osgi.dev.richconsole.internal.upgrade.UpgradeServiceImpl.deployBundles(UpgradeServiceImpl.java:116)
>      at org.everit.osgi.dev.richconsole.internal.BundleDeployerFrame$6$1.run(BundleDeployerFrame.java:242)
>      at java.lang.Thread.run(Thread.java:745)
> Caused by: org.apache.commons.jexl2.parser.ParseException: parse error
>      at org.apache.commons.jexl2.parser.Parser.generateParseException(Parser.java:3935)
>      at org.apache.commons.jexl2.parser.Parser.jj_consume_token(Parser.java:3817)
>      at org.apache.commons.jexl2.parser.Parser.Block(Parser.java:200)
>      at org.apache.commons.jexl2.parser.Parser.Statement(Parser.java:110)
>      at org.apache.commons.jexl2.parser.Parser.JexlScript(Parser.java:72)
>      at org.apache.commons.jexl2.parser.Parser.parse(Parser.java:24)
>      at org.apache.commons.jexl2.JexlEngine.parse(JexlEngine.java:1248)
>      ... 41 more
> {code}



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

Mime
View raw message