commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Pham <tim...@yahoo.com>
Subject XPath getValue("//item") for Map throws StackOverflowException
Date Thu, 22 Mar 2007 18:16:37 GMT
Anyone see this problem before?
The test code is this:

<pre>
    public void testXPath()
    {
        List main = new ArrayList();
        ArrayList list = new ArrayList();
        main.add(list);
        
        Map map1 = new HashMap();
        map1.put("a", "TEST1");
        map1.put("b", "TEST2");
        main.add(map1);
        
        JXPathContext context  = JXPathContext.newContext(main); // passed when replace main
with map1
        context.setLenient(true);
        
        assertEquals("value is not right", "TEST1", context.getValue("//a"));
        assertEquals("value is not right", "TEST2", context.getValue("//b"));
        assertEquals("value is not right", null, context.getValue("//c"));
    }
 
 </pre>

This test run will throw StackOverflowError with
org.apache.common.jxpath.model.beans.CollectionPointer(CollectionPointer.java):202


In reality, main is my bean with HashMap attributes that can contain other attributes. When
using JXPath to provide a uniform way to access my bean attributes, I stumple on this problem.
getValue("//not-exist") didn't return null as expected but go into a loop that consumes all
memory.





Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message