#175 Bug in setXPathSupportClass

closed-fixed
nobody
None
5
2007-12-05
2007-07-15
Malcolm Sparks
No

From freemarker.ext.dom.NodeModel :-

/**
* Set an alternative implementation of freemarker.ext.dom.XPathSupport to use
* as the XPath engine.
* @param cl the class, or <code>null</code> to disable XPath support.
*/
static public void setXPathSupportClass(Class cl) {
if (cl != null && !cl.isAssignableFrom(XPathSupport.class)) {
throw new RuntimeException("Class " + cl.getName()
+ " does not implement freemarker.ext.dom.XPathSupport");
}
xpathSupportClass = cl;
}

The call to isAssignableFrom() will ALWAYS fail, unless called with java.lang.Object.

Obviously the intention is the opposite:

XPathSupport.class.isAssignableFrom(cl);

You might also want to deal with the case of cl being null with a separate message.

I'm quite happy to fix this bug but don't have commit access. If you have a process by which I can send a patch, please let me know and I'll fix up the error so you can review it.

Malcolm Sparks
malcolm@congreve.com

Discussion

  • Logged In: YES
    user_id=546667
    Originator: NO

    Thanks, I have fixed this -- will be part of the next 2.3.x and 2.4 releases.
    The null case meant to be used for disabling XPath support, so it doesn't require separate if.

    Regarding the contributions: If you want to do many fixes/improvements, then you can get SVN commit access quite early here. Otherwise you can attach diff files to the tracker items and like. (Note that we are using the the SVN repository only. The CVS is abandoned.)

     
    • status: open --> open-fixed
     
    • status: open-fixed --> closed-fixed
     
  • Logged In: YES
    user_id=546667
    Originator: NO

    Fixed 2.3.11.