commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joseph Campolongo <JCampolo...@cra.com>
Subject [JXPath] StackOverflow error
Date Fri, 19 May 2006 15:12:02 GMT
I'm running into a StackOverflow error on a call to
'JXPathContext.createPath()' whenever I have a path that looks like
'a/b[1]/c'.  I took a quick look at the code and it appears JXPath, when
trying to create its parent pointer, simply recreates an equivalent
pointer(???).

I'm not sure if my AbstractFactory is incorrect, if JXPath simply doesn't
handle the above case(s), or if this is actually a bug in JXPath.

Here is code to reproduce the problem.


    Map map = new HashMap();
    map.put("a", null);
    
    JXPathContext pathContext = JXPathContext.newContext(map);
    pathContext.setFactory(new AbstractFactory() {
      public boolean createObject(
          JXPathContext context, Pointer pointer, Object parent, String
name, int index) {

        Map parentMap = (Map)parent;
        System.out.println(parent + ":" + name + ":" + index);
        if (index > -1) {
          List list = (List)parentMap.get(name);
          if (list == null) {
            list = new ArrayList();
          }
          int size = list.size();
          for (int i = size; i <= index; i++) {
            list.add(i, null);
          }
          parentMap.put(name, list);
        } else {
          parentMap.put(name, new HashMap());
        }
        return true;
      }
      
    });
    pathContext.createPath("a/b[1]/c");
    
Joseph Campolongo


Mime
View raw message