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] [Commented] (JEXL-161) Assignment to Indexed property is broken in 3.0
Date Fri, 10 Jul 2015 13:49:04 GMT

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

Henri Biestro commented on JEXL-161:
------------------------------------

Without a test case from you, it is very difficult to determine if there is an issue and what
it is.
The following code does behave correctly in 2.0 and 3.0 (besides renaming  - JexlScript vs
Script, JexlEngine vs Engine).
Can you try to describe your issue better - without assumption on the 'why' but just the 'what'
?

{code}
    private static Document getDocument(String xml) throws IOException, SAXException, ParserConfigurationException
{
        DocumentBuilder xmlBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        InputStream stringInputStream = new ByteArrayInputStream(xml.getBytes("UTF-8"));
        return xmlBuilder.parse(stringInputStream);
    }

    @Test
    public void test161() throws Exception {
        final JexlEngine jexl = new Engine();
        final JexlContext jc = new MapContext();

        Document xml = getDocument("<node info='123'/>");
        NamedNodeMap nnm = xml.getLastChild().getAttributes();
        Attr info = (Attr) nnm.getNamedItem("info");
        Assert.assertEquals("123", info.getValue());

        jc.set("x", xml.getLastChild());
        final String y = "456";
        jc.set("y", y);
        JexlScript s = jexl.createScript("x.attribute.info = y");
        Object r = s.execute(jc);
        nnm = xml.getLastChild().getAttributes();
        info = (Attr) nnm.getNamedItem("info");
        Assert.assertEquals(y, r);
        Assert.assertEquals(y, info.getValue());
    }
{code}

> Assignment to Indexed property is broken in 3.0
> -----------------------------------------------
>
>                 Key: JEXL-161
>                 URL: https://issues.apache.org/jira/browse/JEXL-161
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dmitri Blinov
>
> In JEXL 2.1.1 the assignment of XML attribute to org.w3c.dom.Element via setAttribute(java.lang.String
name, java.lang.String value) method worked as suggested - indexed property was resolvable
and assignable. In JEXL 3.0 this is broken - unsolvable property '....' 
> By peeping to Uberspect.java I noticed that the following method 
> public JexlPropertySet getPropertySet(final Object obj, final Object identifier, Object
arg) 
> does not contain any references to IndexedType class to resolve indexed property when
assigning. As it works correctly in 2.1 I do not see any reason for this to be as by design,
so I classify this as a bug.
> The example of JEXL script, sorry I haven't figure out how to provide full test case
here:
> x = xml:child(doc, 'ConfigSet'); x.attribute.ConfigSetNo = '123'.



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

Mime
View raw message